home *** CD-ROM | disk | FTP | other *** search
Wrap
Text File | 2002-10-23 | 298.6 KB | 12,978 lines
# libLSTall global functions shared between several scripts # # Copyright (C) 1993-1997 Ralf Flaxa, LST Software GmbH, Erlangen, Germany # Copyright (C) 1998-2001 Ralf Flaxa, Caldera (Deutschland) GmbH, # Erlangen, Germany # # $Id: libLSTall,v 3.225 2001/04/10 14:28:53 rf Exp $ # # # global settings (should be moved to lst.cnf) # # first it is in MB (for convenience) SPARESPACE=5 # from now on its in Bytes (for granularity) SPARESPACE="`do_calc $SPARESPACE \* 1048576`" NUM_DOINST=0 ROOT_INITIALIZED=0 touch $FILE_VALUES_SEL INSTALL_MODE=OpenLinux Is_SPARC() { if [ "`uname -m`" = "sparc" ]; then return 0 else return 1 fi } if Is_SPARC ; then RPMBINEXT=sparc else RPMBINEXT=i386 fi case $INSTALL_MODE in LST) # LST settings INSTALL_MODE=LST CONF_INSTALL_PATH_SRC=/lst_22 PKGEXT=rpm ;; COL) # LST settings INSTALL_MODE=LST CONF_INSTALL_PATH_SRC=/col PKGEXT=rpm ;; OpenLinux) # LST settings INSTALL_MODE=OpenLinux CONF_INSTALL_PATH_SRC=/col PKGEXT=rpm ;; esac # # libLSTmini # CMD_Still_Missing() { echo "lisa: sorry, command not yet supported..." 1>&2 false } Do_KDE_add() { [ ! -x "$CMD_KDEAPPS" ] || $CMD_KDEAPPS add "$@" } Do_KDE_remove() { local app="$1" local trigger="$2" [ "$trigger" != "0" ] && return 0 [ ! -x "$CMD_KDEAPPS" ] || $CMD_KDEAPPS remove "$app" } Do_SysVinit() { local script= local callname= local levels= while read script callname levels; do for i in `echo $levels | sed -e 's/:/ /g'`; do mkdir -p $DIR_INIT_CONF/rc$i.d >/dev/tty8 2>&1 ln -sf ../init.d/$script $DIR_INIT_CONF/rc$i.d/$callname >/dev/tty8 2>&1 done done } Do_SysVinit_install() { local subsys="$1" local start="$2$1" local slevels="$3" local stop="$4$1" local klevels="$5" # consistency check #FIXME!? # cleanup Do_SysVinit_remove $subsys 0 # create start- and stoplinks local name=$start for l in $slevels $klevels; do for i in `echo $l | sed -e 's/:/ /g'`; do [ -d $DIR_INIT_CONF/rc$i.d ] || mkdir -p $DIR_INIT_CONF/rc$i.d ln -sf ../init.d/$subsys $DIR_INIT_CONF/rc$i.d/$name done name=$stop done } Do_SysVinit_remove() { local subsys="$1" local trigger="$2" [ "$trigger" != "0" ] && return 0 # consistency check #FIXME!? rm -f $DIR_INIT_CONF/rc?.d/[SK][0-9][0-9]$subsys } Info_FindFile() { local topic=$1 local file if [ -n "`echo $topic | sed -n 's:^/.*$:OK:p'`" ]; then if [ -r $topic ]; then file=$topic elif [ -r $topic.info ]; then file=$topic.info elif [ -r $topic.gz ]; then file=$topic.gz elif [ -r $topic.info.gz ]; then file=$topic.info.gz fi elif [ -r $DIR_INFO/$topic ]; then file=$DIR_INFO/$topic elif [ -r $DIR_INFO/$topic.info ]; then file=$DIR_INFO/$topic.info elif [ -r $DIR_INFO/$topic.gz ]; then file=$DIR_INFO/$topic.gz elif [ -r $DIR_INFO/$topic.info.gz ]; then file=$DIR_INFO/$topic.info.gz fi echo $file } Do_Info_install() { Check_Info_Not_OLD || { Do_Info_install_OLD "$@"; return $?; } local topic="$1"; shift local file # consistency check #FIXME!? file=`Info_FindFile $topic` if [ -z "$file" ] || [ ! -r "$file" ]; then Debug "Do_Info_install $topic not found" return 1 fi $CMD_INSTALL_INFO "$@" $file $DIR_INFO/dir return 0 } Do_Info_remove() { Check_Info_Not_OLD || { Do_Info_remove_OLD "$@"; return $?; } local topic="$1"; shift local trigger="$1"; shift local file [ "$trigger" != "0" ] && return 0 # consistency check #FIXME!? file=`Info_FindFile $topic` if [ -z "$file" ] || [ ! -r "$file" ]; then Debug "Do_Info_remove $topic not found" return 1 fi $CMD_INSTALL_INFO --remove $file $DIR_INFO/dir return 0 } # backward-compatibility ... Check_Info_Not_OLD() { local v=`$CMD_INSTALL_INFO --version | sed -n '1s/^[^0-9]*//p'` [ "$v" != "3.11" ] && return 0 return 1 } Info_GetCmd() { local file="$1" local cmd=cat [ -n "`echo $file | sed -n 's/^.*\.gz$/OK/p'`" ] && cmd=zcat echo $cmd } Do_Info_install_OLD() { local topic="$1"; shift local file local cmd # consistency check #FIXME!? file=`Info_FindFile $topic` cmd=`Info_GetCmd $file` if [ -z "$file" ] || [ ! -r "$file" ]; then Debug "Do_Info_install $1 not found" return 1 fi $cmd $file | $CMD_INSTALL_INFO "$@" - $DIR_INFO/dir return 0 } Do_Info_remove_OLD() { local topic="$1" local trigger="$2" local file local cmd [ "$trigger" != "0" ] && return 0 # consistency check #FIXME!? file=`Info_FindFile $topic` cmd=`Info_GetCmd $file` if [ -z "$file" ] || [ ! -r "$file" ]; then Debug "Do_Info_remove $1 not found" return 1 fi $cmd $file | $CMD_INSTALL_INFO --remove - $DIR_INFO/dir return 0 } Do_Inetd_install() { # consistency check in inetdconf!? $CMD_INETDCONF --add "$@" } Do_Inetd_remove() { local service="$1" local trigger="$2" [ "$trigger" != "0" ] && return 0 # further consistency check in inetdconf!? $CMD_INETDCONF --remove "$service" } Do_Inetd() { local command="$1" shift 1 case "$command" in "install"|"remove") Do_Inetd_${command} "$@" return $? ;; "enable"|"disable") [ $# -gt 0 ] && { local service=$1; shift; } [ $# -gt 0 ] && { local trigger=$1; shift; } [ "$trigger" != "0" ] && return 0 # further consistency check in inetdconf!? $CMD_INETDCONF --$command "$service" "$@" return $? ;; *) Print_Usage ;; esac } Do_User() { local command="$1"; shift case "$command" in "create") CMD_Still_Missing ;; "revoke") CMD_Still_Missing ;; *) Print_Usage ;; esac } Do_Group_Join() { local gname="$1"; shift local i for i in "$@"; do false done CMD_Still_Missing } Do_Group_Leave() { CMD_Still_Missing } Do_Group() { local command="$1"; shift local gname="$1"; shift case "$command" in "create") $CMD_GROUP $command $gname "$@" ;; "join") Do_Group_Join $gname "$@" ;; "leave") [ "$1" != "0" ] && return 0; shift Do_Group_Leave $gname "$@" ;; "revoke") [ "$1" != "0" ] && return 0; shift $CMD_GROUP $command $gname "$@" ;; *) Print_Usage ;; esac } # # libAnalyse # Store_Detected_Info() { local cd1_dev # we store all detected hardware infos in /etc/system.cnf as default sysinfo --cdrom --var > /dev/null 2> /tmp/cdrom if [ -s /tmp/cdrom ]; then cd1_dev="`cut -d':' -f 2 /tmp/cdrom | sed -n '1p'`" if [ -n "$cd1_dev" ]; then case $cd1_dev in /dev/sr0) cd1_dev=/dev/scd0 ;; /dev/sr1) cd1_dev=/dev/scd1 ;; esac set_val CONF_CD1_DEV "$cd1_dev" fi fi return 0 } # # libModule # Show_Hardware_Found() { local tmpfile=/tmp/LST/ans local what="HARDWARE" if [ $# -gt 0 -a "$1" = "generic" ]; then what="HARDWARE_GENERIC" fi Info ":INFO_ANALYSE_RUNNING:" sysinfo --notitle --short > $tmpfile if [ ! -s $tmpfile ]; then Msg2 HARDWARE_NOT_FOUND || return 1 return 0 fi Browse2 $tmpfile ${what}_FOUND || return 1 return 0 } Warn_Autoprobe_Dangerous() { Msg2 AUTOPROBE_DANGEROUS || return 1 return 0 } Do_Autoprobe() { local what= local how= # CD probelists (sbpcd takes too much time) local cd_probelist_kernel="cdu31a mcd mcdx sbpcd aztcd sonycd535 gscd arcd bpcd bpmcd dscd eicd epcd kicd oicd pwcd cm206 optcd sjcd isp16" local cd_probelist="cdu31a mcd mcdx aztcd sonycd535 gscd arcd bpcd bpmcd dscd eicd epcd kicd oicd pwcd cm206 optcd sjcd isp16" local cd_probelist_cautious="" # SCSI probelists (g_NCR5380 hangs) local scsi_probelist_kernel="advansys BusLogic u14-34f ultrastor aha152x aha1542 aha1740 aic7xxx fdomain in2000 g_NCR5380 NCR53c406a qlogicfas qlogicisp pas16 seagate t128 dtc tmscsim 53c7,8xx ncr53c8xx eata_dma eata_pio wd7000 eata AM53C974 ppa gdth" local scsi_probelist="advansys BusLogic u14-34f ultrastor aha152x aha1542 aha1740 aic7xxx fdomain in2000 NCR53c406a qlogicfas qlogicisp pas16 seagate t128 dtc tmscsim 53c7,8xx ncr53c8xx eata_dma eata_pio wd7000 eata ppa gdth" local scsi_probelist_cautious="aha1542 ncr53c8xx 53c7,8xx aic7xxx" # net probelists local ether_probelist_cautious="3c59x ne2k-pci 3c509 ne" local ether_probelist_kernel="de4x5 dgrs eepro100 epic100 hp100 ne2k-pci pcnet32 rtl8139 3c59x tulip yellowfin ac3200 smc-ultra32 at1700 smc-ultra smc9194 wd 3c503 hp hp-plus seeq8005 e2100 ne at1500 fmv18x eth16i 3c509 3c515 znet eexpress eepro depca ewrk3 apricot 3c501 3c507 3c505 de600 de620 ni52 ni65 lance tlan" # the at1500 is part of the e2100 ? # the 3c501 is always misdetected :-( # the seeq8005 and znet are not modularized :-( local ether_probelist="de4x5 dgrs eepro100 epic100 hp100 ne2k-pci pcnet32 rtl8139 3c59x tulip yellowfin ac3200 smc-ultra32 at1700 smc-ultra smc9194 wd 3c503 hp hp-plus e2100 ne fmv18x eth16i 3c509 3c515 eexpress eepro depca ewrk3 apricot 3c507 3c505 ni52 ni65 lance tlan atp de600 de620" local driver= local modparam= local all=1 local retval= local success= what="$1" shift 1 case $what in all) # simulate full kernel autoprobing by load & test of all modules # first we probe for CDROMs, then for SCSI hosts and last for ethernet probelist="$cd_probelist $scsi_probelist $ether_probelist" probelist_cautious="$cd_probelist_cautious $scsi_probelist_cautious $ether_probelist_cautious" ;; CD) probelist="$cd_probelist" probelist_cautious="$cd_probelist_cautious" ;; SCSI) probelist="$scsi_probelist" probelist_cautious="$scsi_probelist_cautious" ;; NET) probelist="$ether_probelist" probelist_cautious="$ether_probelist_cautious" ;; esac if [ $# -gt 0 -a "$1" = "cautious" ]; then probelist="$probelist_cautious" all=0 fi Info ":INFO_AUTOPROBE_RUNNING:" for driver in $probelist ; do modparam= if [ "$driver" = "ne" ]; then # NE2000 cards need an io parameter. 0x300 is very common. modparam="io=0x300" fi Debug "probing ${driver} driver:" Do_Load_Module_mini --silent $driver $modparam retval=$? if [ $retval -eq 0 ]; then success=1 fi done if [ -n "$success" ]; then return 0 else return 1 fi } Ask_Autoprobe() { local what="AUTOPROBE" if [ $# -gt 0 -a "$1" = "cautious" ]; then what="AUTOPROBE_CAUTIOUS" fi Ask bool ${what} y || return 1 return 0 } Ask_Hardware_Sufficient() { local what="HARDWARE" local defval=y if [ $# -gt 0 -a "$1" = "generic" ]; then what="HARDWARE_GENERIC" defval=n fi Ask bool ${what}_SUFFICIENT $defval || return 1 return 0 } Find_Module() { if [ -f $1.o ]; then return 0 ; fi if [ -f $1.o.gz ]; then return 0 ; fi if [ -f /floppy/$1.o ]; then return 0 ; fi if [ -f /floppy/$1.o.gz ]; then return 0 ; fi if [ -f /source/$1.o ]; then return 0 ; fi return 1 } Build_Modules_Available() { local modpath=/lib/modules/`uname -r` local mode="$1" local goal="$2" local driver= local modparam= local subdir= local list= local scsi_support="scsi_mod sd_mod sg sr_mod st" local scsi_driver="aha152x aha1542 aha1740 aic7xxx advansys AM53C974 BusLogic tmscsim dtc eata eata_dma eata_pio fdomain gdth in2000 g_NCR5380 ppa in2000 NCR53c406a 53c7,8xx ncr53c8xx pas16 qlogic qlogicfas qlogicisp seagate t128 ultrastor u14-34f wd7000" local cdrom_driver="aztcd cdrom gscd hitcd isp16 cm206 sbpcd mcd mcdx optcd sjcd cdu31a sonycd535 arcd bpcd bpmcd dscd eicd epcd kicd oicd pwcd" local net_support="8390 bsd_comp depca dlci dummy eql new_tunnel plip ppp sdla slhc slip" local net_driver="3c501 3c503 3c505 3c507 3c509 3c59x ac3200 apricot arcnet at1700 atp de4x5 de600 de620 depca dgrs e2100 eepro eepro100 eexpress eth16i ewrk3 fmv18x hp hp-plus hp100 ibmtr lance ne ne2k-pci ni52 ni65 pcnet32 rtl8139 smc9194 smc-ultra smc-ultra32 tlan tulip wd yellowfin" local fs_driver="binfmt_aout binfmt_elf binfmt_java ext ext2 hpfs isofs ncpfs nfs smbfs sysv ufs vfat xiafs" case $goal in FS) list="$fs_driver" modpath=$modpath/fs ;; CD) list="$cdrom_driver" modpath=$modpath/cdrom ;; SCSI) # list="$scsi_support $scsi_driver" list="$scsi_driver" modpath=$modpath/scsi ;; NET) # list="$net_support $net_driver" list="$net_driver" modpath=$modpath/net ;; ANY) echo "\"DONE\" \":MENU_BACK:\" \\" Build_MODULES_AVAILABLE return 0 ;; esac if [ "$mode" = "box" ]; then # echo "\"NONE\" \":TYPE_${goal}_NONE:\" \\" echo "\"DONE\" \":TYPE_${goal}_DONE:\" \\" echo "\"AUTO\" \":TYPE_${goal}_AUTO:\" \\" fi for driver in $list ; do Find_Module $modpath/$driver if [ $? -eq 0 ]; then if [ "$mode" = "box" ]; then echo "\"$driver\" \":TYPE_${goal}_$driver:\" \\" else echo "$driver" fi fi done if [ "$mode" = "box" ]; then echo "\"OTHER\" \":TYPE_${goal}_OTHER:\" \\" fi } Map_LILO_2_Insmod_Param() { local lilo_param="$1" local var1="$2" local var2="$3" local var3="$4" local var4="$5" local val1 local val2 local val3 local val4 if [ -z "`sed -n "/^$lilo_param=/p" $FILE_BOOT_PARAMS`" ]; then echo "" return 1 fi case $lilo_param in aztcd|gscd|cm206|sonycd535|optcd) # for LILO and insmod the params are the same sed -n "/^$lilo_param=/p" $FILE_BOOT_PARAMS return 0 ;; mcd) sed -n '/^mcd=/s/^mcd=\([^,]*\),\(.*\)/mcd_port=\1 mcd_irq=\2/p' $FILE_BOOT_PARAMS return 0 # mcd_port # mcd_irq # mitsumi_bug_93_wait ;; aic7xxx) if [ -n "`sed -n '/^aic7xxx=extended,no_reset/p' $FILE_BOOT_PARAMS`" ]; then echo "aic7xxx_extended=1 aic7xxx_no_reset=1" return 0 fi ;; cdu31a) sed -n '/^cdu31a=/s/^cdu31a=\([^,]*\),\(.*\)/cdu31a_port=\1 cdu31a_irq=\2/p' $FILE_BOOT_PARAMS return 0 # cdu31a_port # cdu31a_irq # sony_pas_init ;; isp16) ;; sbpcd) ;; esac return 0 } Do_Load_Module_mini() { local silent_flag= local ans=/tmp/LST/ans local err=/tmp/LST/err local modpath=/lib/modules/`uname -r` local subpath= local module= local driver= local modparam= local modlist=/tmp/modules.initrd if [ $# -gt 0 -a "$1" = '--silent' ]; then silent_flag=true shift 1 fi driver="$1" shift 1 modparam="$@" if [ -z "$modparam" ]; then # check for LILO boot params case $driver in mcd|gscd|aztcd|cm206|cdu31a|aic7xxx|sonycd535|optcd) modparam="`Map_LILO_2_Insmod_Param $driver`" ;; esac fi # check whether it's already loaded /sbin/lsmod | sed -n "/^$driver/p" > $ans if [ -s $ans ]; then return 0 fi # check whether it's available and prepare it for loading for subpath in block cdrom fs ipv4 misc net pcmcia scsi ; do mkdir -p $modpath/$subpath module="$modpath/$subpath/${driver}.o" if [ -s $module ]; then break elif [ -s $module.gz ]; then gunzip $module.gz break elif [ -s /source/$module ]; then module=/source/$module break elif [ -s /floppy/$module ]; then module=/floppy/$module break elif [ -s /floppy/$module.gz ]; then gzip -dcf /floppy/$module.gz > $module break fi module= done if [ -z "$module" ]; then if [ -z "$silent_flag" ]; then Msg "module ${driver}.o ; :ERR_MODULE_NOT_AVAILABLE:" fi return 1 fi while [ 1 ]; do if [ -z "$silent_flag" ]; then Info "module ${driver}.o ; :INFO_MODULE_LOADING:" sleep 2 fi Debug "trying <insmod $module $modparam> ... " /sbin/insmod $module $modparam >$err 2>&1 && break /sbin/rmmod $driver >/dev/null 2>&1 Debug "insmod ${driver} failed." if [ -z "$silent_flag" ]; then Info "module ${driver}.o ; :ERR_MODULE_LOADING_FAILED:" sleep 3 fi end_use $module return 1 done Debug "insmod ${driver} succeeded." # FIXME: in the success case we do not compress the module any more # end_use $module if [ -z "$silent_flag" ]; then Msg "module ${driver}.o ; :INFO_MODULE_LOADED:" fi echo "$driver" >> $modlist mkdir -p /etc/modules/options if [ -n "$modparam" ]; then echo "$modparam" > /etc/modules/options/$driver else rm -f /etc/modules/options/$driver fi return 0 } Load_Default_Modules() { local driver= for driver in $@ ; do Do_Load_Module_mini --silent $driver "" || return 1 done return 0 } Choose_Module() { local modpath=/lib/modules/`uname -r` local goal="$1" local driver=AUTO local insmod_params= local default_cd="" local default_scsi="scsi_mod sd_mod sr_mod st sg" local default_ether="8390" local default_modules= case $goal in CD) default_modules="$default_cd" ;; SCSI) default_modules="$default_scsi" ;; NET) default_modules="$default_ether" ;; ANY) MountModulesFloppy ;; esac Load_Default_Modules $default_modules while [ 1 ]; do Ask one MODULE_LOAD --default "$driver" Build_Modules_Available box $goal || return 1 driver="$ANSWER" insmod_params= # if [ "$driver" = "NONE" ]; then if [ "$driver" = "DONE" ]; then return 0 fi if [ "$driver" = "OTHER" ]; then MountModulesFloppy continue fi if [ "$driver" = "ne" ]; then insmod_params="io=0x300" ; fi if [ "$driver" = "AUTO" ]; then Ask_Autoprobe if [ "$ANSWER" != "0" ]; then continue fi Warn_Autoprobe_Dangerous || continue Do_Autoprobe $goal || return 1 Show_Hardware_Found || continue return 0 fi # do not offer new features for COL 1.1 installs if [ "`uname -r`" = "2.0.29" ]; then Ask string MODULE_PARAM $insmod_params || continue else Menu_Module_Param "$driver" || continue fi insmod_params="$ANSWER" Do_Load_Module_mini $driver $insmod_params || return 1 Show_Hardware_Found || continue return 0 done return 0 } Build_Module_Analyse() { cat << EOF "BACK" ":MENU_BACK:" \\ "CHECK" ":INFO_HARDWARE_FOUND:" \\ "LOADED" ":MENU_MODULE_SHOW_LOADED:" \\ "SYSINFO" ":MENU_ANALYSE:" \\ "DMESG" ":SHOW_BOOT_MSG:" \\ "REPORT" ":DO_WRITE_ANALYSE_INFOS:" \\ EOF } Menu_Module_Analyse() { local action=CHECK while [ 1 ]; do Ask menu MODULE_ANALYSE --default "$action" Build_Module_Analyse $action || return 1 action="$ANSWER" case $action in BACK) return 0 ;; CHECK) Show_Hardware_Found ;; LOADED) Menu_Module_Show_Loaded ;; SYSINFO) Show_Analyse_Info ;; DMESG) Show_Boot_Msg ;; REPORT) Write_Analyse_Infos ;; esac done } Build_Module_Load() { local subsys= echo "\"BACK\" \":MENU_BACK:\" \\" for subsys in CD SCSI NET ANY ; do echo "\"$subsys\" \":MENU_MODULE_LOAD_$subsys:\" \\" done } Menu_Module_Load_mini() { local action while [ 1 ]; do action= Ask one MODULE_LOAD --default "$action" Build_Module_Load $action || return 1 action="$ANSWER" if [ "$action" = "BACK" ]; then return 0 fi Choose_Module $action || continue done } Build_Modules_Loaded() { echo "\"BACK\" \":MENU_BACK:\" \\" cat /proc/modules | do_quote } Menu_Module_Remove_mini() { Ask one MODULE_REMOVE Build_Modules_Loaded || return 1 if [ "$ANSWER" = "BACK" ]; then return 0 fi /sbin/rmmod $ANSWER || return 1 return 0 } Build_Config_Modules() { cat << EOF "DONE" ":MENU_CONFIG_MODULES_DONE:" \\ "ANALYSE" ":MENU_MODULE_ANALYSE:" \\ "LOAD" ":MENU_MODULE_LOAD:" \\ "REMOVE" ":MENU_MODULE_REMOVE:" \\ EOF } Menu_Config_Modules() { local action=CHECK while [ 1 ]; do Ask menu CONFIG_MODULES --default "$action" Build_Config_Modules $action || return 1 action="$ANSWER" case $action in DONE) return 0 ;; ANALYSE) Menu_Module_Analyse ;; LOAD) Menu_Module_Load_mini ;; REMOVE) Menu_Module_Remove_mini ;; esac done } # # libInit # InitSubsystems() { local subsys= local subsys_state # If we run from the lisa live filesystem then we skip the first steps if [ -n "`sed -n '/^er=/p' /tmp/cmdline | fgrep text`" ]; then subsys_state=8 else subsys_state=3 fi # first try all subsystems rm -f /tmp/subsystems for subsys in PCMCIA SCSI NET CD ; do echo "$subsys" >> /tmp/subsystems done # load generic 8390 ethernet driver module Load_Default_Modules 8390 # load SCSI high level protocol driver Load_Default_Modules scsi_mod sd_mod sr_mod st sg # load filesystems Load_Default_Modules nfs isofs # Only run PCMCIA probing if we are not running from the lisa live filesystem if [ -z "`sed -n '/^er=/p' /tmp/cmdline | fgrep text`" ]; then # check and load PCMCIA subsystem if Is_SPARC ; then Debug "Skipping probe for PCMCIA on SPARC!" else InitPCMCIA fi fi while [ 1 ]; do subsys_state="`do_calc $subsys_state - 1`" case $subsys_state in 0) return 1 ;; 1) Msg ":ERR_BACKSTEP_NOT_POSSIBLE:" Ask_Bool ABORT_INSTALL y if [ "$ANSWER" = "0" ]; then Do_Reboot fi ;; 2) Show_Hardware_Found generic || continue ;; 3) Ask_Hardware_Sufficient generic || continue if [ "$ANSWER" = "0" ]; then # this lets us jump to Menu_Config_Modules subsys_state=20 continue fi ;; 4) Ask_Autoprobe cautious || continue if [ "$ANSWER" != "0" ]; then # this lets us jump to Menu_Config_Modules subsys_state=11 continue fi ;; 5) Warn_Autoprobe_Dangerous || continue Do_Autoprobe all cautious subsys_state="`do_calc $subsys_state + 1`" ;; 6) Msg ":ERR_BACKSTEP_NOT_POSSIBLE:" Ask_Bool ABORT_INSTALL y if [ "$ANSWER" = "0" ]; then Do_Reboot fi ;; 7) Show_Hardware_Found || continue ;; 8) Ask_Hardware_Sufficient || continue if [ "$ANSWER" = "0" ]; then # this lets us jump to Menu_Config_Modules subsys_state=20 continue fi subsys_state="`do_calc $subsys_state + 1`" ;; 9) Msg ":ERR_BACKSTEP_NOT_POSSIBLE:" Ask_Bool ABORT_INSTALL y if [ "$ANSWER" = "0" ]; then Do_Reboot fi ;; 10) Menu_Config_Modules || continue ;; *) Info ":INFO_WAIT:" Store_Detected_Info # If we run from the lisa live filesystem then bootpc was already run # so we do not have to rerun it but can limit it to reading out results if [ -n "`sed -n '/^er=/p' /tmp/cmdline | fgrep text`" ]; then Read_BOOTP_Info else Get_BOOTP_Info fi return 0 ;; esac subsys_state="`do_calc $subsys_state + 2`" done } # # libPCMCIA # HasPCMCIA() { Debug "searching for PCMCIA controllers with probe:" prep_use PCMCIA_PROBE /sbin/probe >/tmp/pcmcia 2>&1 if [ $? -eq 0 ]; then Debug "probe returned with 0" Debug "PCMCIA chip found! Asking for PCMCIA Support!" Ask bool PCMCIA_SUPPORT y || return 1 if [ "$ANSWER" != "0" ]; then return 1 ; fi MountModulesFloppy else Debug "probe returned with non 0" Debug "No supported PCMCIA chip found! Skipping PCMCIA!" return 1 fi return 0 } UnpackPCMCIA() { mkdir -p /lib/modules/`uname -r`/pcmcia Debug "Memory usage before PCMCIA unpack:" free > /dev/tty8 Debug "disk usage before PCMCIA unpack:" df > /dev/tty8 prep_use PCMCIA Debug "Memory usage after PCMCIA unpack:" free > /dev/tty8 Debug "disk usage after PCMCIA unpack:" df > /dev/tty8 return 0 } RemovePCMCIA() { not_use PCMCIA_PROBE not_use PCMCIA } InitPCMCIA() { local pcic= local chip= local modpath= local retval=1 if [ -z "`fgrep -x PCMCIA /tmp/subsystems`" ]; then return 0 fi modpath=/lib/modules/`uname -r`/pcmcia HasPCMCIA || return 1 UnpackPCMCIA || return 1 # /bin/sh /etc/rc.d/rc.pcmcia # this will be replaced by rc.pcmcia while [ 1 ]; do Load_Default_Modules pcmcia_core || break # the chip should be derived automatically from the probe command # see /tmp/pcmcia for chip in i82365 tcic ; do Load_Default_Modules $chip if [ $? -eq 0 ]; then pcic=$chip Load_Default_Modules ds break fi done if [ -z "$pcic" ]; then break ; fi if [ ! -s /sbin/cardmgr ]; then break ; fi /sbin/cardmgr || break pcic="ok" break done if [ "$pcic" != "ok" ]; then if [ -z "$pcic" ]; then Debug "No supported PCMCIA chip found! Skipping PCMCIA!" fi if [ -s /var/run/cardmgr.pid ]; then kill `cat /var/run/cardmgr.pid` sleep 1 fi /sbin/rmmod ds >/dev/null 2>&1 /sbin/rmmod tcic >/dev/null 2>&1 /sbin/rmmod i82365 >/dev/null 2>&1 /sbin/rmmod pcmcia_core >/dev/null 2>&1 else Debug "$chip PCMCIA chip detected!" Debug "Ask to insert PCMCIA cards" Msg ":DO_INSERT_PCMCIA_CARDS:" retval=0 fi # remove all PCMCIA modules from the ramdisk to save space RemovePCMCIA return $retval } Set_If_Unset() { if [ -z "`get_val $1`" ]; then set_val $1 "$2" fi } Get_netprobe_Info() { local retval local probes="`get_val CONF_SETUP_NETPROBE_PROBES`" local probe_hostname local probe_gateway local probe_nameserver local probe_netmask local probe_nisdomain local probe_nisserver local probe_string local bpf=/tmp/netprobe.out local debug_tty local fqhn= local eth0_ip= local eth0_mask= local eth0_bcast= local eth0_net= local router1_ip= # local dns_domain= # local dns_search= local dns_server1_ip= # local dns_server2_ip= # local dns_server3_ip= local nfs_server1_ip= local nfs_server1_path= local nis_domain= local nis_server1_ip= # If we run from the lisa live filesystem then use tty4 for debug output if [ -n "`sed -n '/^er=/p' /tmp/cmdline | fgrep text`" ]; then debug_tty=/dev/tty4 else debug_tty=/dev/tty7 fi if [ "`get_val CONF_SETUP_USE_NETPROBE`" != "on" ]; then return 1 ; fi if [ -z "$probes" ]; then return 1 ; fi if [ ! -x /usr/bin/netprobe ]; then return 1 ; fi Info ":INFO_NETPROBE_RUNNING: ; ; :INFO_WAIT:" sleep 2 # building probe_string echo "$probes" | fgrep netmask > /dev/null if [ $? -eq 0 ]; then probe_netmask=true probe_string="$probe_string -p netmask" fi echo "$probes" | fgrep nisdomain > /dev/null if [ $? -eq 0 ]; then probe_nisdomain=true probe_string="$probe_string -p nisdomain" fi echo "$probes" | fgrep nameserver > /dev/null if [ $? -eq 0 ]; then probe_nameserver=true probe_string="$probe_string -p nameserver" fi echo "$probes" | fgrep nisserver > /dev/null if [ $? -eq 0 ]; then probe_nisserver=true probe_string="$probe_string -p nisserver" fi echo "$probes" | fgrep hostname > /dev/null if [ $? -eq 0 ]; then probe_hostname=true probe_string="$probe_string -p hostname" fi echo "$probes" | fgrep gateway > /dev/null if [ $? -eq 0 ]; then probe_gateway=true probe_string="$probe_string -p gateway" fi # remark: lo and eth0 has to be up and running, so the IP address # has to be known echo "running netprobe..." > $debug_tty /usr/bin/netprobe $probe_string > $bpf 2> $debug_tty retval=$? if [ $retval -ne 0 ]; then echo "netprobe returns with <$retval>" > $debug_tty # return 1 fi if [ ! -s $bpf ]; then echo "netprobe returns no output" > $debug_tty return 1 fi echo "netprobe returns:" > $debug_tty cat $bpf > $debug_tty while [ 1 ]; do Browse2 $bpf NETPROBE_OUTPUT || return 1 Ask_Bool USE_NETPROBE_OUTPUT || continue if [ "$ANSWER" != "0" ]; then return 1 ; fi break done fqhn="`get_val -f $bpf HOSTNAME`" if [ -n "$probe_hostname" -a -n "$fqhn" ]; then Set_If_Unset CONF_FQ_HOSTNAME "$fqhn" fi # FIXME eth0_ip="`get_val CONF_eth0_IP`" eth0_net="`get_val CONF_eth0_NET`" eth0_mask="`get_val -f $bpf NETMASK`" eth0_bcast="`get_val -f $bpf BROADCAST`" if [ -n "$eth0_mask" -a -n "$eth0_ip" -a -n "$probe_netmask" ]; then Set_If_Unset CONF_eth0_MASK "$eth0_mask" Set_If_Unset CONF_eth0_BCAST "$eth0_bcast" # now reconfigure eth0 interface ifconfig eth0 down 2> $debug_tty ifconfig lo down 2> $debug_tty ifconfig lo 127.0.0.1 2> $debug_tty route add -net 127.0.0.0 2> $debug_tty ifconfig eth0 $eth0_ip netmask $eth0_mask broadcast $eth0_bcast 2> $debug_tty route add -net $eth0_net 2> $debug_tty fi router1_ip="`get_val -f $bpf GATEWAY`" if [ -n "$probe_gateway" -a -n "$router1_ip" ]; then Set_If_Unset CONF_ROUTER1_IP "$router1_ip" fi dns_server1_ip="`get_val -f $bpf DNSSERVER1`" # dns_server2_ip="`get_val -f $bpf DNSSRVS`" # dns_server3_ip="`get_val -f $bpf DNSSRVS`" if [ -n "$probe_nameserver" -a -n "dns_server1_ip" ]; then # Set_If_Unset CONF_DNS_DOMAIN "$dns_domain" # Set_If_Unset CONF_DNS_SEARCH "$dns_search" Set_If_Unset CONF_DNS_SERVER1_IP "$dns_server1_ip" # Set_If_Unset CONF_DNS_SERVER2_IP "$dns_server2_ip" # Set_If_Unset CONF_DNS_SERVER3_IP "$dns_server3_ip" fi nis_domain="`get_val -f $bpf NISDOMAIN`" if [ -n "$probe_nisdomain" -a -n "$nis_domain" ]; then Set_If_Unset CONF_NIS_DOMAIN "$nis_domain" fi nis_server1_ip="`get_val -f $bpf NISSERVER1 | cut -d':' -f 1`" if [ -n "$probe_nisserver" -a -n "$nis_server1_ip" ]; then Set_If_Unset CONF_NIS_SERVER1_IP "$nis_server1_ip" fi # Set_If_Unset CONF_NFS_SERVER1_IP "$nfs_server1_ip" # Set_If_Unset CONF_NFS_SERVER1_PATH "$nfs_server1_path" } Read_BOOTP_Info() { local bpf=/tmp/bootpc.out local debug_tty=/dev/tty4 local fqhn= local eth0_ip= local eth0_mask= local eth0_bcast= local router1_ip= # local dns_domain= # local dns_search= local dns_server1_ip= # local dns_server2_ip= # local dns_server3_ip= local nfs_server1_ip= local nfs_server1_path= local nis_domain= local nis_server1_ip= if [ ! -s $bpf ]; then echo "bootpc returns no output" > $debug_tty return 1 fi echo "bootpc returns:" > $debug_tty cat $bpf > $debug_tty while [ 1 ]; do Browse2 $bpf BOOTP_OUTPUT || return 1 Ask_Bool USE_BOOTP_OUTPUT || continue if [ "$ANSWER" != "0" ]; then return 1 ; fi break done fqhn="`get_val -f $bpf HOSTNAME`" eth0_ip="`get_val -f $bpf IPADDR`" eth0_mask="`get_val -f $bpf NETMASK`" eth0_bcast="`get_val -f $bpf BROADCAST`" router1_ip="`get_val -f $bpf GATEWAYS | sed 's/ .*//'`" dns_server1_ip="`get_val -f $bpf DNSSRVS | sed 's/ .*//'`" # dns_server2_ip="`get_val -f $bpf DNSSRVS`" # dns_server3_ip="`get_val -f $bpf DNSSRVS`" nis_domain="`get_val -f $bpf NISDOMAIN`" nis_server1_ip="`get_val -f $bpf NISSERVER | sed 's/ .*//'`" set_val CONF_FQ_HOSTNAME "$fqhn" set_val CONF_eth0_IP "$eth0_ip" set_val CONF_eth0_MASK "$eth0_mask" set_val CONF_eth0_BCAST "$eth0_bcast" set_val CONF_ROUTER1_IP "$router1_ip" Set_If_Unset CONF_NFS_SERVER1_IP "$nfs_server1_ip" Set_If_Unset CONF_NFS_SERVER1_PATH "$nfs_server1_path" # set_val CONF_DNS_DOMAIN "$dns_domain" # set_val CONF_DNS_SEARCH "$dns_search" set_val CONF_DNS_SERVER1_IP "$dns_server1_ip" # set_val CONF_DNS_SERVER2_IP "$dns_server2_ip" # set_val CONF_DNS_SERVER3_IP "$dns_server3_ip" set_val CONF_NIS_DOMAIN "$nis_domain" set_val CONF_NIS_SERVER1_IP "$nis_server1_ip" } Get_BOOTP_Info() { local retval local bpf=/tmp/bootpc.out local debug_tty=/dev/tty4 if [ "`get_val CONF_SETUP_USE_BOOTP`" != "on" ]; then return 1 ; fi if [ ! -x /usr/bin/bootpc ]; then return 1 ; fi Info ":INFO_BOOTP_RUNNING: ; ; :INFO_WAIT:" sleep 2 ifconfig eth0 down 2> $debug_tty ifconfig lo down 2> $debug_tty ifconfig lo 127.0.0.1 2> $debug_tty route add -net 127.0.0.0 2> $debug_tty ifconfig eth0 0.0.0.0 netmask 0.0.0.0 broadcast 0.0.0.0 2> $debug_tty route add -net 0.0.0.0 2> $debug_tty echo "running bootpc..." > $debug_tty /usr/bin/bootpc > $bpf 2> $debug_tty retval=$? ifconfig eth0 down 2> $debug_tty ifconfig lo down 2> $debug_tty if [ $retval -ne 0 ]; then echo "bootpc returns with <$retval>" > $debug_tty return 1 fi Read_BOOTP_Info } ####################################################################### # libLSTcheck check functions shared between several scripts # # Copyright (C) 1993-1997 Ralf Flaxa, LST Software GmbH, Erlangen, Germany # # check arguments for a function # Check_Args() { if [ $# -lt 3 ]; then Panic "Check_Args :ERR_WRONG_NUM_OF_ARGS: ($#)" Panic "function Check_Args (wanted 4 args, got $# args) ; args=<$@> ; :ERR_WRONG_NUM_OF_ARGS:" return 1 fi if [ $2 -ne $3 ]; then Panic "function $1 (wanted $2 args, got $3 args) ; args=<$4> ; :ERR_WRONG_NUM_OF_ARGS:" return 1 fi return 0 } # test a string against a valid char list # returns 0 if all chars of string are in the valid_char_list # returns 1 if invalid chars are found and echos invalid chars # Check_Chars_Valid() { local f_name=Check_Chars_Valid local f_args=2 # (string, validchars) -> Check_Args $f_name $f_args $# "$@" || return 255 # Test for invalid chars dummy=`echo $1 | sed "s/[$2]//g"` if [ ! -z "$dummy" ]; then echo "$dummy" return 1 else return 0 fi } Check_Chroot() { if [ "$DIR_TARGET" != "/" ]; then $CMD_BOX --title ":WARNING:" --msg "$1 ; :ERR_IMPOSSIBLE_WITH_CHROOT:" return 1 fi return 0 } Is_Expert() { local f_name=Is_Expert local f_args=0 # MODE_USER -> Check_Args $f_name $f_args $# "$@" || return 255 if [ "$MODE_USER" = "expert" ]; then return 0 else return 1 fi } Has_File() { if [ $# -lt 1 ]; then Panic "missing arg to Has_File" fi if [ -s $1 ]; then return 0 else if [ -f $1 ]; then Debug "$f_name: $1: file is empty." else Debug "$f_name: $1: file is not installed." if [ $# -gt 1 ]; then Error "$2" fi fi return 1 fi } # check if a file exists # Check_File() { local f_name=Check_File local f_args=1 # (file) -> Check_Args $f_name $f_args $# "$@" || return 255 if [ -f $1 ]; then return 0 else return 1 fi } # search for a string (exact match) in a file # Check_Found() { local f_name=Check_Found local f_args=2 # (string, file) -> Check_Args $f_name $f_args $# "$@" || return 255 if [ -z "$1" ]; then Debug "Check_Found: arg 1 is empty" return 2 fi if [ -z "$2" ]; then Debug "Check_Found: arg 2 is empty" return 3 fi if [ ! -s $2 ]; then Debug "Check_Found: $2: file empty or nonexistent" return 4 fi fgrep -x $1 $2 >/dev/null 2>&1 || return 1 return 0 } # checks if a path is valid and sets STATUS to the type and # and if false ERROR to an error message # Check_Path_Valid() { local f_name=Check_Path_Valid local f_args=1 # (path) -> STATUS,ERROR export STATUS= export ERROR= Check_Args $f_name $f_args $# "$@" || return 255 if [ -L $1 ]; then STATUS="symlink" elif [ -d $1 ]; then STATUS="directory" elif [ -f $1 ]; then STATUS="file" else ERROR="$1 ; :ERR_INVALID_PATH:" return 1 fi return 0 } # Call action_func and depending on success the corresponding func # Do_Action() { local f_name=Do_Action local f_args=3 # (action_func, success_func, error_func) -> Check_Args $f_name $f_args $# "$@" || return 255 eval $1 if [ $? -eq 0 ]; then eval $2 return 0 else eval $3 return 1 fi } Do_Analyse_All() { sysinfo --var > $FILE_TMP_MSG.tmp 2> $FILE_BOOT_DIAG.tmp sed -e 's/ sr=/ scd=/g' -e 's:/dev/sr:/dev/scd:g' < $FILE_TMP_MSG.tmp > $FILE_TMP_MSG sed -e 's/:sr=/:scd=/g' -e 's:/dev/sr:/dev/scd:g' < $FILE_BOOT_DIAG.tmp > $FILE_BOOT_DIAG rm -f $FILE_BOOT_DIAG.tmp $FILE_TMP_MSG.tmp sleep 2 } Do_Backup_File() { local file=$1 if [ -f $file ]; then cp -a $file ${file}~ fi } # # filter right edition from libLSTall # Do_Filter_libLSTall() { local edition=$1 local omit= case $edition in CND) omit="LST" ;; *) omit="CND" ;; esac sed -e '/^#%#ifdef '$omit'/,/^#%#endif '$omit'/d' \ -e '/^#%#/d' } # # filter right language and edition from libLSTtext # Do_Filter_libLSTtext() { local edition=$1 local lang=$2 sed "{ s/^${lang}-$edition> // s/^${lang}-x> // s/^x-$edition> // s/^x-x> // /^[a-z]\{2\}-[A-Za-z]\{3,5\}> /d /^x-[A-Za-z]\{3,5\}> /d /^[a-z]\{2\}-x> /d }" } Do_Merge_libLSTtext() { local floppy_lib="$1" local cd_lib="$2" local labels_new="ASK_ETHER_REMOTE_IP_TEXT ASK_ETHER_REMOTE_IP_TITLE TYPE_CD_arcd TYPE_CD_bpcd TYPE_CD_bpmcd TYPE_CD_dscd TYPE_CD_eicd TYPE_CD_epcd TYPE_CD_kicd TYPE_CD_oicd TYPE_CD_pwcd TYPE_PARALLEL_DEV_lp0 TYPE_PARALLEL_DEV_lp1 TYPE_PARALLEL_DEV_lp2 TYPE_PRINTER_PostScript" local label # the libLSTtext-mini on the floppy is more up to date # and also may contain labels the libLSTtext CD version # doesn't have. # The trick is to keep what's in the mini version only # and to append the CD version # if they are the same, then take the one from the CD if [ "`sed -n '/^# $Id/p' $floppy_lib`" = "`sed -n '/^# $Id/p' $cd_lib`" ]; then cp -a $cd_lib $floppy_lib return 0 fi # otherwise take the floppy header sed -n '1,/^:/{ /^:/d p }' $floppy_lib > ${floppy_lib}.new # add the new labels for label in $labels_new ; do sed -n "/^:$label:/,/^:/{ /^:$label:/p /^:/d p }" $floppy_lib >> ${floppy_lib}.new done # and append the old CD version cat $cd_lib >> ${floppy_lib}.new mv ${floppy_lib}.new $floppy_lib return 0 } # try to lookup a short filename for a given long filename # by a 'trans.tbl' file # Do_Lookup_Trans_Tbl() { local dir="`dirname $1`" local TransTblFile="$dir/trans.tbl" local LongName="`basename $1`" local PkgRegexProof="`echo "$LongName" | sed 's/\+/\\\+/g'`" local ShortName= Debug "Called Do_Lookup_Trans_Tbl $1" if [ ! -f $TransTblFile ]; then Debug "trans.tbl file $TransTblFile not found" return 1 fi # using cut to circumvent broken sed ShortName="`sed -n '/[ ]'${PkgRegexProof}'$/p' $TransTblFile | cut -c 3-14`" Debug "ShortName=<$ShortName>" if [ ! -z "$ShortName" -a -r "$dir/$ShortName" ]; then export ANSWER="$dir/$ShortName" return 0 fi return 1 } Do_Clear_Screen() { echo "c" } # Do_Config_Update ( CONFIG_FILE ) # # Reset config file with current values # Do_Config_Update() { # Wipe out old configuration and prepare new ( sed -n " /^$/ { s/^/echo/p d } /^#/ { s/^\(.*\)/echo \'\1\'/p d } s/^\(.*\)=\(.*\)/echo \"\1=\$\1\"/p " ) < $1 > $1.$$.tmp if [ $? != 0 ]; then Panic "Do_Config_Update: error in sed call" return 1 fi # Analyse system to get valid settings # Analyse_System -all # Erase old config file . $1.$$.tmp >> $1.$$.tmp2 rm -f $1.$$.tmp # Requote Variables sed '/^[^#]/s/^\(.*\)=\(.*\)/\1=\"\2\"/' < $1.$$.tmp2 > $1 rm -f $1.$$.tmp2 } Do_Prompt() { echo -n "press any key to continue" get_key > /dev/null echo } # Do_Store ( VAR VAL [CONFIG_FILE] ) # Do_Store() { local conf_file=$FILE_SYSTEM_CONF if [ $# -eq 3 ]; then conf_file=$3 elif [ $# -ne 2 ]; then Panic "got $# instead of 2 or 3 args!" fi # store in config file set_val -f $conf_file "$1" "$2" echo "$1=\"$2\"" > $FILE_TMP_VAL . $FILE_TMP_VAL rm -f $FILE_TMP_VAL } Do_Symlink() { local f_name=Do_Symlink local f_args=2 # (orig, symlink) -> local dir1 local dir2 local file1 local file2 Check_Args $f_name $f_args $# "$@" || return 255 dir1="`dirname $1`" dir2="`dirname $2`" file1="`basename $1`" file2="`basename $2`" if [ ! -d $DIR_TARGET/$dir1 ]; then mkdir -p $DIR_TARGET/$dir1 fi if [ ! -d $DIR_TARGET/$dir2 ]; then mkdir -p $DIR_TARGET/$dir2 fi if [ "$dir1" = "$dir2" ]; then ( cd $DIR_TARGET/$dir2 ; ln -sf $file1 $file2 ) else ( cd $DIR_TARGET/$dir2 ; ln -sf $1 $file2 ) fi } # Do_Translate STRING [DICTIONARY] # Do_Translate() { local my_lang="`get_val CONF_LST_LANG`" local dict=/usr/lib/LST/$my_lang/libLSTtext if [ $# -gt 1 ]; then dict="$2" fi $CMD_BOX -t --dictionary $dict --text "$1" } Get_Val() { if [ $# -gt 1 ]; then get_val -d "$2" -f $FILE_SYSTEM_CONF "$1" else get_val -f $FILE_SYSTEM_CONF "$1" fi } Show_Analyse_Info() { Do_Analyse_All Browse2 $FILE_TMP_MSG ANALYSE || return 1 return 0 } Show_Hardware_Info() { Do_Analyse_All sysinfo --hardware > $FILE_TMP_MSG Browse2 $FILE_TMP_MSG ANALYSE || return 1 return 0 } Show_Kernel_Info() { Do_Analyse_All sysinfo --kernel > $FILE_TMP_MSG Browse2 $FILE_TMP_MSG ANALYSE || return 1 return 0 } Show_Partition_Info() { Do_Analyse_All sysinfo --partition > $FILE_TMP_MSG Browse2 $FILE_TMP_MSG ANALYSE || return 1 return 0 } Show_System_Info() { Do_Analyse_All sysinfo --system > $FILE_TMP_MSG Browse2 $FILE_TMP_MSG ANALYSE || return 1 } # libLSTconfig - configuration library shared between several scripts # # Copyright (C) 1993-1997 Ralf Flaxa, LST Software GmbH, Erlangen, Germany # Menu_Config_Tape() { local tape Choose --none --other --menutitle ":CHOOSE_TAPE_DEV_MENUTITLE:" TAPE_DEV CONF_TAPE1_DEV || return 1 tape="$ANSWER" Do_Store CONF_TAPE1_DEV "$tape" if [ -n "$tape" ]; then Do_Symlink $tape /dev/tape Do_Load_Driver tape $tape || return 1 fi ANSWER="$tape" return 0 } Menu_Config_CD() { local cdrom= if [ "`get_val -f /etc/lst.cnf CONF_COL_EDITION`" = "SBA" ]; then ANSWER="`get_val CONF_CD1_DEV`" if [ -z "$ANSWER" ]; then Choose --none --other --menutitle ":CHOOSE_CD_DEV_MENUTITLE:" CD_DEV CONF_CD1_DEV || return 1 fi else Choose --none --other --menutitle ":CHOOSE_CD_DEV_MENUTITLE:" CD_DEV CONF_CD1_DEV || return 1 fi cdrom="$ANSWER" Do_Store CONF_CD1_DEV "$cdrom" if [ -n "$cdrom" ]; then Do_Symlink $cdrom /dev/cdrom Do_Load_Driver filesystem iso9660 || return 1 Do_Load_Driver cdrom $cdrom || return 1 fi ANSWER="$cdrom" return 0 } Build_KEYBOARD() { cat << EOF "us.map" ":TYPE_KEYBOARD_US:" \\ "uk.map" ":TYPE_KEYBOARD_UK:" \\ "de-latin1-nodeadkeys.map" ":TYPE_KEYBOARD_GERMAN:" \\ "fr-latin1.map" ":TYPE_KEYBOARD_FRENCH:" \\ "it.map" ":TYPE_KEYBOARD_ITALIAN:" \\ "fi-latin1.map" ":TYPE_KEYBOARD_FINISH:" \\ "es.map" ":TYPE_KEYBOARD_SPANISH:" \\ "br.map" ":TYPE_KEYBOARD_BRAZILIAN_PORTUGUESE:" \\ EOF } Menu_Config_Keyboard() { Check_Chroot ":MENU_CONFIG_KEYBOARD:" || return 1 while [ 1 ]; do Choose KEYBOARD CONF_KEYBOARD_MAP || return 1 CONF_KEYBOARD_MAP="$ANSWER" if [ ! -f /usr/lib/kbd/keytables/$ANSWER ]; then if [ -f /usr/lib/kbd/keytables/${ANSWER}.gz ]; then gzip -df /usr/lib/kbd/keytables/${ANSWER}.gz else $CMD_BOX --msg "$ANSWER ; :ERR_KEYMAP_NOT_AVAILABLE:" continue fi fi # save old keymap dumpkeys > $DIR_LST_TMP/keymap.old loadkeys $CONF_KEYBOARD_MAP > /dev/null 2>&1 $CMD_BOX --string ":DO_TEST_KEYMAP:" 2> $FILE_TMP_ANSWER $CMD_BOX --bool ":ASK_KEEP_KEYMAP:" 2> $FILE_TMP_ANSWER || return 1 ANSWER="`cat $FILE_TMP_ANSWER`" if [ $ANSWER -eq 0 ]; then break else loadkeys $DIR_LST_TMP/keymap.old > /dev/null 2>&1 rm -f $DIR_LST_TMP/keymap.old continue fi done Do_Store CONF_KEYBOARD_MAP "$CONF_KEYBOARD_MAP" Set_keyboard } Do_Setup_Modem() { local dev= local speed= local type= local faxid= # re-read values dev="`Get_Val CONF_MODEM1_DEV`" speed="`Get_Val CONF_MODEM1_SPEED`" type="`Get_Val CONF_MODEM1_TYPE`" faxid="`Get_Val CONF_MODEM1_FAXID`" if [ -z "$dev" ]; then return 0 fi # setup mgetty if [ -f $FILE_MGETTY_CONF ]; then rm -f $FILE_MGETTY_CONF.tmp touch $FILE_MGETTY_CONF.tmp chmod 600 $FILE_MGETTY_CONF.tmp sed "{ s/^fax-id.*$/fax-id $faxid/ s/^speed.*$/speed $speed/ }" $FILE_MGETTY_CONF >> $FILE_MGETTY_CONF.tmp mv $FILE_MGETTY_CONF.tmp $FILE_MGETTY_CONF fi # setup sendfax if [ -f $FILE_SENDFAX_CONF ]; then rm -f $FILE_SENDFAX_CONF.tmp touch $FILE_SENDFAX_CONF.tmp chmod 600 $FILE_SENDFAX_CONF.tmp sed "{ s%^fax-id.*$%fax-id $faxid% s%^fax-devices.*$%fax-devices $dev% }" $FILE_SENDFAX_CONF >> $FILE_SENDFAX_CONF.tmp mv $FILE_SENDFAX_CONF.tmp $FILE_SENDFAX_CONF fi # setup symlink Do_Symlink $dev /dev/modem } Build_MODEM() { cat << EOF "" ":TYPE_MODEM_NONE:" \\ "Hayes" ":TYPE_MODEM_HAYES:" \\ "Zyxel" ":TYPE_MODEM_ZYXEL:" \\ "Rockwell" ":TYPE_MODEM_ROCKWELL:" \\ "Hayes" ":TYPE_MODEM_UNKNOWN:" \\ EOF } Menu_Config_Modem() { local type= local dev= local speed= local faxid= while [ 1 ]; do Choose MODEM CONF_MODEM1_TYPE CONF_MODEM1_TYPE || return 1 type="$ANSWER" if [ -z "$type" ]; then dev= speed= type= faxid= rm -f /dev/modem else Choose --other --menutitle ":CHOOSE_SERIAL_DEV_MENUTITLE:" SERIAL_DEV CONF_MODEM1_DEV || continue dev="$ANSWER" if [ "$dev" = "`Get_Val CONF_MOUSE1_DEV`" ]; then Warn ":WARN_MOUSE_MODEM_DEV_CONFLICT:" || continue fi if [ "$dev" = "`Get_Val CONF_PRINTER1_DEV`" ]; then Warn ":WARN_MODEM_PRINTER_DEV_CONFLICT:" || continue fi Choose SERIAL_SPEED CONF_MODEM1_SPEED || continue speed="$ANSWER" if [ -f $FILE_SENDFAX_CONF ]; then faxid="`Get_Val CONF_MODEM1_FAXID`" Ask_String MODEM_FAXID "$faxid" || continue faxid="$ANSWER" fi fi Do_Store CONF_MODEM1_DEV "$dev" Do_Store CONF_MODEM1_SPEED "$speed" Do_Store CONF_MODEM1_TYPE "$type" Do_Store CONF_MODEM1_FAXID "$faxid" Do_Setup_Modem return 0 done } Build_MOUSE() { if Is_SPARC ; then cat << EOF "Sun standard /dev/sunmouse" ":TYPE_MOUSE_SUN:" \\ EOF else cat << EOF "PS2 ps/2 /dev/psaux" ":TYPE_MOUSE_PS2_BUS:" \\ "MouseMan mmseries serial" ":TYPE_MOUSE_MOUSEMAN_SERIAL:" \\ "Microsoft microsoft serial" ":TYPE_MOUSE_MICROSOFT_SERIAL:" \\ "Microsoft busmouse /dev/bmousems" ":TYPE_MOUSE_MICROSOFT_BUS:" \\ "Logitech logitech serial" ":TYPE_MOUSE_LOGITECH_SERIAL:" \\ "Logitech busmouse /dev/bmouselogitec" ":TYPE_MOUSE_LOGITECH_BUS:" \\ "MouseSystems mousesystems serial" ":TYPE_MOUSE_MOUSESYSTEMS_SERIAL:" \\ "ATI_XL busmouse /dev/bmouseatixl" ":TYPE_MOUSE_ATI_BUS:" \\ EOF fi cat << EOF "" ":TYPE_MOUSE_NONE:" \\ EOF } Menu_Config_Mouse() { local type= local xtype= local dev= local buttons= while [ 1 ]; do Choose MOUSE || return 1 if [ -z "$ANSWER" ]; then buttons= dev= type= xtype= else read type xtype dev << EOF $ANSWER EOF if [ "$dev" = "serial" ]; then Choose --other --menutitle ":CHOOSE_SERIAL_DEV_MENUTITLE:" SERIAL_DEV CONF_MOUSE1_DEV || continue dev="$ANSWER" if [ "$dev" = "`Get_Val CONF_MODEM1_DEV`" ]; then Warn ":WARN_MOUSE_MODEM_DEV_CONFLICT:" || continue fi if [ "$dev" = "`Get_Val CONF_PRINTER1_DEV`" ]; then Warn ":WARN_MOUSE_PRINTER_DEV_CONFLICT:" || continue fi fi Do_Symlink $dev /dev/mouse fi Do_Store CONF_MOUSE1_BUTTONS "$buttons" Do_Store CONF_MOUSE1_DEV "$dev" Do_Store CONF_MOUSE1_TYPE "$type" Do_Store CONF_MOUSE1_X_TYPE "$xtype" if [ -n "$xtype" -a "$DIR_TARGET" = "/" ]; then Do_Setup_X fi return 0 done } Build_PRINTER_DEV() { List box PARALLEL_DEV List box USB_PRINTER_DEV List box SERIAL_DEV } Start_unconfigured_sh() { local uconfsh=/etc/rc.d/unconfigured.sh echo '#!/bin/sh' > $DIR_TARGET/$uconfsh echo "echo -n \"Updating databases:\" " >> $DIR_TARGET/$uconfsh } Finish_unconfigured_sh() { local uconfsh=/etc/rc.d/unconfigured.sh echo 'if [ -x /usr/bin/mandb ]; then ' >> $DIR_TARGET/$uconfsh echo "echo -n \" mandb\" " >> $DIR_TARGET/$uconfsh echo '/usr/bin/mandb -c > /tmp/mandb.log 2>&1 & ' >> $DIR_TARGET/$uconfsh echo 'fi' >> $DIR_TARGET/$uconfsh echo "echo" >> $DIR_TARGET/$uconfsh # append finish.sh downloaded from TFTP Server (auto install mode only) if [ -f /etc/rc.d/finish.sh ]; then cat /etc/rc.d/finish.sh >> $DIR_TARGET/$uconfsh fi echo "mv $uconfsh $uconfsh.done" >> $DIR_TARGET/$uconfsh chmod 755 $DIR_TARGET/$uconfsh } Fix_Paper_Size() { local paper="`get_val CONF_PRINTER1_PAPER`" case $paper in a3) paper="A3" ;; a4) paper="A4" ;; a5) paper="A5" ;; letter) paper="Letter" ;; legal) paper="Legal" ;; ledger) paper="Letter" ;; esac set_val CONF_PRINTER1_PAPER "$paper" } Do_Setup_Printer() { local dir_default_ppd=$DIR_TARGET/etc/cups/ppd local dir_pool_ppd=$DIR_TARGET/usr/share/cups/model local file_printers_conf=$DIR_TARGET/etc/cups/printers.conf local printer_type="`get_val CONF_PRINTER1_TYPE`" local file_ppd="`get_val CONF_PRINTER1_PPD`" local file_default_ppd= local dev="`get_val CONF_PRINTER1_DEV`" local device_URI= local speed="`get_val CONF_PRINTER1_SPEED`" local host="`get_val CONF_PRINTER1_HOST`" local name="`get_val CONF_PRINTER1_NAME`" local name_default="ps1" local res="`get_val CONF_PRINTER1_RES`" local paper if [ -z "$name" ]; then name="$name_default" fi Fix_Paper_Size paper="`get_val CONF_PRINTER1_PAPER`" if [ -z "$paper" ]; then paper="Letter" fi if [ -z "$speed" ]; then speed="9600" fi if [ -z "$dev" ]; then device_URI="parallel:/dev/lp0" else case $dev in /dev/lp0|/dev/lp1|/dev/lp2) device_URI="parallel:${dev}" ;; /dev/ttyS0|/dev/ttyS1|/dev/ttyS2|/dev/ttyS3) device_URI="serial:${dev}"'?'"baud=$speed" ;; /dev/usb/lp0|/dev/usb/lp1|/dev/usb/lp2) device_URI="usb:${dev}" ;; esac fi file_default_ppd=${dir_default_ppd}/${name}.ppd mkdir -p $dir_default_ppd sed "{ \;^\*Default.*Letter[ ]*$;s;Letter;${paper}; }" ${dir_pool_ppd}/${file_ppd} > $file_default_ppd if [ ! -f $file_printers_conf ]; then Debug "$file_printers_conf: file not found" Debug "Skipping manipulation of it." return 1 fi sed '{ /^# The following/,$d }' $file_printers_conf > ${file_printers_conf}.tmp chmod 644 ${file_printers_conf}.tmp mv ${file_printers_conf}.tmp $file_printers_conf cat << EOF >> $file_printers_conf # The following configuration is written by Caldera LISA on `date` <DefaultPrinter ${name}> Info ${printer_type} Location DeviceURI ${device_URI} Accepting Yes JobSheets none none </Printer> EOF } Build_CUPS_Printers() { local file_printers_db=$DIR_LIVE/lizard/share/apps/lizard/printers if [ ! -f $file_printers_db ]; then file_printers_db=$DIR_TARGET/usr/share/hwdata/printers fi if [ ! -f $file_printers_db ]; then echo "$file_printers_db: file not found." return 1 fi # Our sed is horribly old and broken, so we have to work around it cut -d':' -f 1,2,6,7 $file_printers_db | \ sed '{ /^#/d s/:/ / s/:/ / s/ /,/g }' | do_quote | \ sed '{ s/:/;/ s/:.* "/"/ s/;/:/ s/,/ /g }' } Menu_Config_Printer_cups() { local type= local ppd= local dev= local speed= local res= local paper= local print_rm= local print_rp= local pnum= Fix_Paper_Size while [ 1 ]; do Choose --none --other --build Build_CUPS_Printers PRINTER CONF_PRINTER1_TYPE || return 1 type="`echo $ANSWER | cut -d':' -f 1`" ppd="`echo $ANSWER | cut -d':' -f 2`" if [ -z "$type" ]; then type= ppd= dev= speed= else # printer device Choose --other --menutitle ":CHOOSE_PRINTER_DEV_MENUTITLE:" PRINTER_DEV CONF_PRINTER1_DEV || return 1 dev="$ANSWER" if [ -n "`echo $dev | fgrep /dev/ttyS `" ]; then if [ "$dev" = "`Get_Val CONF_MOUSE1_DEV`" ]; then Warn ":WARN_MOUSE_PRINTER_DEV_CONFLICT:" || continue fi if [ "$dev" = "`Get_Val CONF_MODEM1_DEV`" ]; then Warn ":WARN_MODEM_PRINTER_DEV_CONFLICT:" || continue fi # printer serial portspeed Choose SERIAL_SPEED CONF_PRINTER1_SPEED || continue speed="$ANSWER" else speed= fi # FIXME: ask Klaus about printer resolution # printer resolution #Choose PRINTER_RES CONF_PRINTER1_RES || continue #res="$ANSWER" # printer paper size Choose PRINTER_PAPER CONF_PRINTER1_PAPER || continue paper="$ANSWER" fi Do_Store CONF_PRINTER1_TYPE "$type" Do_Store CONF_PRINTER1_PPD "$ppd" Do_Store CONF_PRINTER1_DEV "$dev" Do_Store CONF_PRINTER1_SPEED "$speed" Do_Store CONF_PRINTER1_HOST "$print_rm" Do_Store CONF_PRINTER1_NAME "$print_rp" Do_Store CONF_PRINTER1_RES "$res" Do_Store CONF_PRINTER1_PAPER "$paper" Do_Setup_Printer return 0 done } Menu_Config_Printer_lpd() { local type= local dev= local speed= local res= local paper= local print_rm= local print_rp= local file_lpd_conf=$DIR_TARGET/etc/lpd.conf local print_grp_def=daemon local print_grp= local uconfsh=/etc/rc.d/unconfigured.sh local print_genfilter=$DIR_TARGET/usr/lib/LST/lisa/genfilter local print_template=$DIR_TARGET/usr/lib/LST/lisa/filter-template local pnum= if [ -f $file_lpd_conf ]; then # compiled-in value overwritten? print_grp="`get_val -f $file_lpd_conf group`" if [ -z "$print_grp" ]; then # compiled-in value mentionned? print_grp="`fgrep group= $file_lpd_conf | sed -n '1,1p' | cut -d'=' -f 2`" fi fi if [ -z "$print_grp" ]; then print_grp="$print_grp_def" fi while [ 1 ]; do # printer type Choose --none --other PRINTER CONF_PRINTER1_TYPE || return 1 type="$ANSWER" if [ -z "$type" ]; then type= dev= speed= elif [ "$type" = "NET" ]; then print_rm="`Get_Val CONF_PRINTER1_HOST`" Ask_String PRINTER_REMOTE_HOST "$print_rm"|| return 1 print_rm="$ANSWER" print_rp="`Get_Val CONF_PRINTER1_NAME`" if [ -z "$print_rp" -o "$MODE_QUERY" != "auto" ]; then print_rp="ps" fi Ask_String PRINTER_REMOTE_DEV "$print_rp" || return 1 print_rp="$ANSWER" type="NET" else # printer device Choose --other --menutitle ":CHOOSE_PRINTER_DEV_MENUTITLE:" PRINTER_DEV CONF_PRINTER1_DEV || return 1 dev="$ANSWER" if [ -n "`echo $dev | fgrep /dev/ttyS `" ]; then if [ "$dev" = "`Get_Val CONF_MOUSE1_DEV`" ]; then Warn ":WARN_MOUSE_PRINTER_DEV_CONFLICT:" || continue fi if [ "$dev" = "`Get_Val CONF_MODEM1_DEV`" ]; then Warn ":WARN_MODEM_PRINTER_DEV_CONFLICT:" || continue fi # printer serial portspeed Choose SERIAL_SPEED CONF_PRINTER1_SPEED || continue speed="$ANSWER" else speed= fi # printer resolution Choose PRINTER_RES CONF_PRINTER1_RES || continue res="$ANSWER" # printer paper size Choose PRINTER_PAPER CONF_PRINTER1_PAPER || continue paper="$ANSWER" fi Do_Store CONF_PRINTER1_TYPE "$type" Do_Store CONF_PRINTER1_DEV "$dev" Do_Store CONF_PRINTER1_SPEED "$speed" Do_Store CONF_PRINTER1_HOST "$print_rm" Do_Store CONF_PRINTER1_NAME "$print_rp" Do_Store CONF_PRINTER1_RES "$res" Do_Store CONF_PRINTER1_PAPER "$paper" if [ -n "$type" ]; then # we have configured a printer # FIXME: Uaaahhh! # if printcap exists we disable everything with '#' if [ -f $DIR_TARGET/etc/printcap ]; then cp -a $DIR_TARGET/etc/printcap $DIR_TARGET/etc/printcap.lisasave sed '/^[^#]/s/^/#/' $DIR_TARGET/etc/printcap.lisasave \ > $DIR_TARGET/etc/printcap fi if [ "$type" = "NET" ]; then # it is a network printer # add network entry to /etc/printcap cat << EOF >> $DIR_TARGET/etc/printcap ##PRINTTOOL## REMOTE lp|ps:\\ :sd=/var/spool/lpd/lp:\\ :mx#0:\\ :rm=$print_rm:\\ :rp=$print_rp: EOF else # it is a local printer if [ -n "$dev" ]; then # make sure printer dev has the right settings chown root.${print_grp} $DIR_TARGET/${dev} chmod 660 $DIR_TARGET/${dev} fi # add local entry to /etc/printcap cat << EOF >> $DIR_TARGET/etc/printcap ##PRINTTOOL## LOCAL $type $res $paper {} ps:\\ :sd=/var/spool/lpd/ps:\\ :mx#0:\\ :lp=$dev:\\ :if=/var/spool/lpd/ps/filter:\\ :sh: ##PRINTTOOL## LOCAL lp:\\ :sd=/var/spool/lpd/lp:\\ :mx#0:\\ :lp=$dev:\\ :sh: EOF mkdir -p $DIR_TARGET/var/spool/lpd/ps if [ ! -f $print_genfilter ]; then print_genfilter=$DIR_TARGET/usr/lib/rhs/control-panel/genfilter print_template=$DIR_TARGET/usr/lib/rhs/control-panel/filter-template fi $print_genfilter $type $res $paper \ < $print_template \ > $DIR_TARGET/var/spool/lpd/ps/filter chmod 755 $DIR_TARGET/var/spool/lpd/ps/filter fi # FIXME: create lp devices that match in owner.group what LPRng expects for pnum in 0 1 2 ; do rm -f $DIR_TARGET/dev/lp${pnum} mknod -m 660 $DIR_TARGET/dev/lp${pnum} c 6 ${pnum} chown root.${print_grp} $DIR_TARGET/dev/lp${pnum} done # check permissions if [ "$DIR_TARGET" != "/" ]; then echo 'if [ -x /usr/sbin/checkpc ]; then ' >> $DIR_TARGET/$uconfsh echo "echo -n \" checkpc\" " >> $DIR_TARGET/$uconfsh echo '/usr/sbin/checkpc -f > /tmp/checkpc.log 2>&1 ' >> $DIR_TARGET/$uconfsh # simple FIX (once only) for broken checkpc in LST 2.2 echo ' if [ -f /var/spool/lpd/ps/filter ]; then' >> $DIR_TARGET/$uconfsh echo ' chmod +x /var/spool/lpd/ps/filter' >> $DIR_TARGET/$uconfsh echo ' fi' >> $DIR_TARGET/$uconfsh echo 'fi' >> $DIR_TARGET/$uconfsh else if [ -x /usr/sbin/checkpc ]; then /usr/sbin/checkpc -f > /tmp/checkpc.log 2>&1 /etc/rc.d/init.d/lpd restart > /dev/null 2>&1 fi fi fi return 0 done } Choose_Lang() { local i local lang_list_supported="us de fr it es" local lang_list_available="" local my_lang="`get_val CONF_LST_LANG`" local fixed_title="Language Selection" local fixed_message="The following languages are currently available. Use the arrow keys to select." for i in $lang_list_supported ; do if [ -f /usr/lib/LST/$i/libLSTtext ]; then lang_list_available="$lang_list_available $i" fi done if [ -z "$lang_list_available" ]; then Error "No language choice available." return 1 fi cat << EOF > /tmp/LST/command #!/bin/sh $CMD_BOX --title "$fixed_title" \\ --default "$my_lang" \\ --one "$fixed_message" \\ EOF for i in $lang_list_available ; do case $i in us) echo "\"us\" \"English\" \\" >> /tmp/LST/command ;; de) echo "\"de\" \"Deutsch\" \\" >> /tmp/LST/command ;; fr) echo "\"fr\" \"Franτais\" \\" >> /tmp/LST/command ;; it) echo "\"it\" \"Italiano\" \\" >> /tmp/LST/command ;; es) echo "\"es\" \"Espa±ol\" \\" >> /tmp/LST/command ;; esac done echo "2> /tmp/LST/answer" >> /tmp/LST/command chmod 755 /tmp/LST/command sh /tmp/LST/command if [ -s /tmp/LST/answer ]; then my_lang="`cat /tmp/LST/answer`" fi set_val CONF_LST_LANG "$my_lang" return 0 } Menu_Config_Term() { while [ 1 ]; do Choose TERM || return 1 export TERM="$ANSWER" Ask_String TERM_TEST && break done Do_Store TERM "$TERM" return 0 } Menu_Config_Printer() { if [ -x $DIR_TARGET/usr/sbin/cupsd ]; then Menu_Config_Printer_cups || return 1 return 0 else Menu_Config_Printer_lpd || return 1 return 0 fi } Menu_Config_Timezone() { local tz_flag="`Get_Val CONF_KERNTZ_FLAG`" local tz_zone="`Get_Val CONF_TIMEZONE`" Choose KERNTZ $tz_flag || return 1 Debug "KERNTZ=<$ANSWER>" if [ "$ANSWER" = "KTZ_UTCTIME" ]; then Do_Store CONF_KERNTZ_FLAG "u" else Do_Store CONF_KERNTZ_FLAG "" fi Choose TIMEZONE $tz_zone || return 1 Do_Store CONF_TIMEZONE "$ANSWER" Set_clock return 0 } Get_Symlink() { ls -l $1 | sed 's/^.* -> \(.*\)/\1/p' } Get_X_Server() { if [ -f $DIR_TARGET/usr/X11R6/bin/X ]; then basename `Get_Symlink $DIR_TARGET/usr/X11R6/bin/X` fi } Do_Setup_X() { local uconfsh=/etc/rc.d/unconfigured.sh local server="unknown" local label local tool if [ $# -gt 0 ]; then server="$1" else server="`Get_X_Server`" fi case $server in XFree86) label=KXCONFIG tool=kxconfig ;; Xaccel) label=XSETUP tool=Xsetup ;; Xmetro) label=CONFIGX tool=configX ;; *) if [ -x $DIR_TARGET/usr/X11R6/bin/XF86Setup ]; then label=XF86SETUP tool=XF86Setup elif [ -x $DIR_TARGET/usr/X11R6/bin/xf86config ]; then label=XF86CONFIG tool=xf86config fi ;; esac Msg2 NEED_CALL_${label} || return 1 return 0 } Menu_Config_X_Server() { local x_server= x_server= while [ 1 ]; do List X_SERVER | sed 's/ :.*$//' > $FILE_TMP_ANSWER if [ ! -s $FILE_TMP_ANSWER ]; then Error2 X_SERVER_NOT_INSTALLED Debug "NO X_Server found !?" return 1 fi if [ -n "`sed '1d' $FILE_TMP_ANSWER`" ]; then Choose X_SERVER $x_server || return 1 x_server="$ANSWER" else x_server="`cat $FILE_TMP_ANSWER`" Debug "taking '$x_server' from List X_SERVER" fi if [ -f /usr/X11R6/bin/$x_server ]; then break fi if [ -f $DIR_TARGET/usr/X11R6/bin/$x_server ]; then break fi Error2 X_SERVER_NOT_INSTALLED done Do_Store CONF_X_SERVER1_TYPE "$x_server" ( cd $DIR_TARGET/usr/X11R6/bin ; rm -f X ; ln -sf $x_server X ) Do_Setup_X $x_server return 0 } Menu_Analyse() { while [ 1 ]; do $CMD_BOX --help ":MENU_ANALYSE_HELP:" \ --title ":MENU_ANALYSE_TITLE:" \ --menu ":MENU_ANALYSE_TEXT:" \ "Show_System_Info" ":MENU_ANALYSE_SYSTEM:" \ "Show_Kernel_Info" ":MENU_ANALYSE_KERNEL:" \ "Show_Hardware_Info" ":MENU_ANALYSE_HARDWARE:" \ "Show_Partition_Info" ":MENU_ANALYSE_PARTITION:" \ "Menu_Analyse_Net" ":MENU_ANALYSE_NET:" \ "Show_Boot_Msg" ":SHOW_BOOT_MSG:" \ "Show_LST_Config" ":SHOW_LST_CONFIG:" \ "Show_System_Config" ":SHOW_SYSTEM_CONFIG:" 2> $FILE_TMP_ANSWER if [ $? -ne 0 ]; then return 1 fi COMMAND="`cat $FILE_TMP_ANSWER`" $COMMAND done } Menu_Config_Hardware() { local item= while [ 1 ]; do if [ -z "$item" ]; then item="Menu_Config_Floppy" ; fi $CMD_BOX --help ":MENU_CONFIG_HARDWARE_HELP:" \ --default "$item" \ --title ":MENU_CONFIG_HARDWARE_TITLE:" \ --menu ":MENU_CONFIG_HARDWARE_TEXT:" \ "Menu_Config_Floppy" ":MENU_CONFIG_FLOPPY:" \ "Menu_Config_Harddisk" ":MENU_CONFIG_HARDDISK:" \ "Menu_Config_Keyboard" ":MENU_CONFIG_KEYBOARD:" \ "Menu_Config_Modem" ":MENU_CONFIG_MODEM:" \ "Menu_Config_Mouse" ":MENU_CONFIG_MOUSE:" \ "Menu_Config_Printer" ":MENU_CONFIG_PRINTER:" \ "Menu_Config_CD" ":MENU_CONFIG_CD:" \ "Menu_Config_Tape" ":MENU_CONFIG_TAPE:" \ "Menu_Config_X_Server" ":CHOOSE_X_SERVER:" 2> $FILE_TMP_ANSWER || break COMMAND="`cat $FILE_TMP_ANSWER`" item="$COMMAND" if [ -n "$COMMAND" ]; then $COMMAND fi done return 0 } Menu_Config_System() { local item= while [ 1 ]; do if [ -z "$item" ]; then item="Menu_Config_User" ; fi $CMD_BOX --help ":MENU_CONFIG_SYSTEM_HELP:" \ --default "$item" \ --title ":MENU_CONFIG_SYSTEM_TITLE:" \ --menu ":MENU_CONFIG_SYSTEM_TEXT:" \ "Menu_Config_User" ":MENU_CONFIG_USER:" \ "Menu_Config_Mount" ":MENU_CONFIG_MOUNT:" \ "Menu_Config_Swap" ":MENU_CONFIG_SWAP:" \ "Menu_Config_FQ_Name" ":MENU_CONFIG_HOSTNAME:" \ "Menu_Config_Timezone" ":CHOOSE_TIMEZONE:" \ "Menu_Config_Daemons" ":MENU_CONFIG_DAEMONS:" \ "Menu_Config_Kernel" ":MENU_CONFIG_KERNEL:" 2> $FILE_TMP_ANSWER || break COMMAND="`cat $FILE_TMP_ANSWER`" item="$COMMAND" if [ -n "$COMMAND" ]; then $COMMAND fi done return 0 } Menu_Config() { local item= while [ 1 ]; do if [ -z "$item" ]; then item="Menu_Config_System" ; fi $CMD_BOX --help ":MENU_CONFIG_HELP:" \ --default "$item" \ --title ":MENU_CONFIG_TITLE:" \ --menu ":MENU_CONFIG_TEXT:" \ "Menu_Config_Hardware" ":MENU_CONFIG_HARDWARE:" \ "Menu_Config_System" ":MENU_CONFIG_SYSTEM:" \ "Menu_Config_Net" ":MENU_CONFIG_NET:" \ "Menu_Config_LILO_HD" ":MENU_CONFIG_BOOT:" 2> $FILE_TMP_ANSWER || break COMMAND="`cat $FILE_TMP_ANSWER`" item="$COMMAND" if [ -n "$COMMAND" ]; then $COMMAND fi done return 0 } Menu_Main() { local item= History "`date` $LOGNAME: LISA: calling main" while [ 1 ]; do if [ -z "$item" ]; then item="Menu_Config" ; fi $CMD_BOX --help ":MENU_MAIN_HELP:" \ --default "$item" \ --title ":MENU_MAIN_TITLE:" \ --menu ":MENU_MAIN_TEXT:" \ "Menu_Analyse" ":MENU_ANALYSE:" \ "Menu_Pkg" ":MENU_PKG:" \ "Menu_Config" ":MENU_CONFIG:" \ "hilfe" ":MENU_HELP:" 2> $FILE_TMP_ANSWER || break COMMAND="`cat $FILE_TMP_ANSWER`" item="$COMMAND" if [ -n "$COMMAND" ]; then $COMMAND fi done return 0 } Menu_Setup() { History "`date` $LOGNAME: LISA: calling setup" Choose_Lang # Menu_Config_Term } Do_Setup_locate() { local uconfsh=/etc/rc.d/unconfigured.sh echo 'if [ -x /usr/bin/updatedb ]; then ' >> $DIR_TARGET/$uconfsh echo "echo -n \" locate\" " >> $DIR_TARGET/$uconfsh echo '/usr/bin/updatedb --prunepaths="/tmp /proc /mnt /var/tmp /var/spool /dev /net /auto /amd" --netuser=nobody > /dev/null 2>&1 &' >> $DIR_TARGET/$uconfsh echo 'fi' >> $DIR_TARGET/$uconfsh } Do_Setup_teTeX() { local uconfsh=/etc/rc.d/unconfigured.sh echo 'if [ -x /usr/TeX/bin/texconfig ]; then ' >> $DIR_TARGET/$uconfsh echo "echo -n \" teTeX\" " >> $DIR_TARGET/$uconfsh echo '( cd /usr/TeX/bin ; texhash > /dev/null 2>&1 )' >> $DIR_TARGET/$uconfsh echo '( cd /usr/TeX/bin ; texconfig init > /dev/null 2>&1 )' >> $DIR_TARGET/$uconfsh echo 'fi' >> $DIR_TARGET/$uconfsh } # libLSTboot - boot config library shared between several scripts # # Copyright (C) 1993-1997 Ralf Flaxa, LST Software GmbH, Erlangen, Germany # Do_Create_Generic_LILO_Message() { rm -f $FILE_LILO_MESSAGE touch $FILE_LILO_MESSAGE || return 1 chmod 400 $FILE_LILO_MESSAGE || return 1 cat << EOF >> $FILE_LILO_MESSAGE LILO Bootloader (LST Linux generic message) Press <TAB> to see possible boot choices. Then enter the desired choice or press <Return>" to boot the default (first) choice." EOF return 0 } Do_Create_Generic_LILO_Conf() { local target="$1" rm -f $DIR_TARGET/$FILE_LILO_CONF.tmp cat << EOF > $DIR_TARGET/$FILE_LILO_CONF.tmp # # general section # EOF if Is_SPARC ; then cat << EOF >> $DIR_TARGET/$FILE_LILO_CONF.tmp root = $target partition = 1 EOF else cat << EOF >> $DIR_TARGET/$FILE_LILO_CONF.tmp boot = $target install = /boot/boot.b EOF fi cat << EOF >> $DIR_TARGET/$FILE_LILO_CONF.tmp message = $FILE_LILO_MESSAGE prompt # wait 20 seconds (200 10ths) for user to select the entry to load timeout = 200 # # default entry # EOF chmod 600 $DIR_TARGET/$FILE_LILO_CONF.tmp return 0 } Check_LILO() { rm -f /tmp/mbr if [ $# -gt 0 ]; then dd if=$1 bs=1 skip=2 count=4 of=/tmp/mbr 2> /dev/null else dd if=/dev/hda bs=1 skip=2 count=4 of=/tmp/mbr 2> /dev/null if [ ! -s /tmp/mbr ]; then dd if=/dev/sda bs=1 skip=2 count=4 of=/tmp/mbr 2> /dev/null fi fi if [ ! -s /tmp/mbr ]; then rm -f /tmp/mbr return 1 else fgrep LILO /tmp/mbr > /dev/null if [ $? -eq 0 ]; then ANSWER="LILO" else ANSWER="unknown" fi fi rm -f /tmp/mbr return 0 } Build_KERNEL_IMAGE() { List_KERNEL_IMAGE $1 | do_quote } Build_LILO_ENTRY() { Build_KERNEL_IMAGE $1 Build_Other_OS } List_KERNEL_IMAGE() { local prefix="$1" local prefixed_image local image for prefixed_image in $prefix/vmlinuz* $prefix/boot/vmlinuz* ; do if [ -f $prefixed_image ]; then image="`echo $prefixed_image | sed "s:^$prefix::"`" echo "$image (Linux Kernel Image)" fi done } Build_Other_OS() { local i= # check for Linux partitions with LILO for i in `sysinfo --tag -C Linux --partition` ; do Check_LILO $i if [ $? -eq 0 -a "$ANSWER" = "LILO" ]; then sysinfo --postlabel " (LILO)" --box -P $i --partition fi done sysinfo --postlabel " (DOS or OS/2)" --box -C DOSC --partition sysinfo --postlabel " (OS/2)" --box -C Bootmanager --partition sysinfo --postlabel " (BSD)" --box -C BSD --partition sysinfo --postlabel " (Solaris?)" --box -C Solaris --partition } Build_LILO_ADD_ENTRY() { cat << EOF "END" ":TYPE_LILO_ADD_ENTRY_NONE:" \\ EOF Build_KERNEL_IMAGE $1 Build_Other_OS } Build_LILO_MODE() { local boot_mode= Is_Expert if [ $? -eq 0 ]; then # echo "\"FLOPPY\" \":TYPE_LILO_MODE_FLOPPY:\" \\" echo "\"LILOACTIVE\" \":TYPE_LILO_MODE_ACTIVE:\" \\" echo "\"LILOPASSIVE\" \":TYPE_LILO_MODE_PASSIVE:\" \\" else echo "\"LILOACTIVE\" \":TYPE_LILO_MODE_ACTIVE:\" \\" echo "\"ROOT\" \":TYPE_LILO_MODE_PASSIVE:\" \\" fi echo "\"MBR\" \":TYPE_LILO_MODE_MBR:\" \\" echo "\"NONE\" \":TYPE_LILO_MODE_NONE:\" \\" } Build_LILO_TARGET() { local root_part="$1" local protect_root= if [ $# -gt 1 -a "$2" = "msdos" ]; then protect_root=true fi if [ -n "`sysinfo --tag --disk | fgrep -x /dev/hda`" ]; then echo "\"/dev/hda\" \":TYPE_LILO_TARGET_MBR_IDE:\" \\" fi if [ -n "`sysinfo --tag --disk | fgrep -x /dev/sda`" ]; then echo "\"/dev/sda\" \":TYPE_LILO_TARGET_MBR_SCSI:\" \\" fi if [ -n "`sysinfo --tag --disk | fgrep -x /dev/rd/c0d0`" ]; then echo "\"/dev/rd/c0d0\" \":TYPE_LILO_TARGET_MBR_SCSI: (/dev/rd/c0d0)\" \\" fi if [ -n "`sysinfo --tag --disk | fgrep -x /dev/ida/c0d0`" ]; then echo "\"/dev/ida/c0d0\" \":TYPE_LILO_TARGET_MBR_SCSI: (/dev/ida/c0d0)\" \\" fi if [ -z "$protect_root" ]; then echo "\"$root_part\" \":TYPE_LILO_TARGET_ROOT: ($root_part)\" \\" fi if [ -n "`sysinfo --expert --tag -C LILOPASSIVE --partition | fgrep -v $root_part`" ]; then echo "\"OTHER\" \":TYPE_LILO_TARGET_OTHER:\" \\" fi echo "\"/dev/fd0\" \":TYPE_LILO_TARGET_FLOPPY:\" \\" echo "\"NONE\" \":TYPE_LILO_TARGET_NONE:\" \\" return 0 } Build_LILO_TARGET_OTHER() { local root_part="$1" sysinfo --box --partition -C LILOPASSIVE | fgrep -v "\"$root_part\"" # expert users may like to install LILO in extended partitions sysinfo --box --partition -C extended } Do_Analyse_Boot_Setup() { local mbr= local dummy= local bios_boot= local active_partitions= local os2_bootmgr= local lilo_in_mbr= echo "======================================================================" echo " LISA boot analysis" echo "======================================================================" echo # check if there is a LILO in the MBR echo "Analysis of Master Boot Record (MBR)" echo "------------------------------------" mbr="`sysinfo --tag -C MBR --disk`" Check_LILO $mbr if [ $? -eq 0 -a "$ANSWER" = "LILO" ]; then lilo_in_mbr=true cat << EOF MBR already contains a LILO Boot Manager This LILO can be replaced now by another LILO, left alone, or (for DOS systems) replaced by DOS's default MBR by using the DOS 'FDISK /MBR' command EOF else echo "No LILO found in the MBR." fi echo # first look for active partitions active_partitions="`sysinfo --tag -C active --partition`" echo "Active partition analysis" echo "-------------------------" if [ -z "$active_partitions" ]; then echo "No active partitions found!" else sysinfo --label -C active --partition fi echo echo "Conclusion" echo "----------" if [ -n "$lilo_in_mbr" ]; then echo "===> The BIOS will boot from the master boot record $mbr." echo return 0 fi # the BIOS will boot from the first active partition bios_boot="`sysinfo --tag -C active --partition | sed -n '1p'`" if [ -z "$bios_boot" ]; then echo "===> it seems you have no valid boot setup!" echo "===> you have 2 choices to fix that:" echo "A.) install a boot loader/manager in the master boot record" echo " of your first hard disk." echo "B.) install a boot loader/manager in a primary partition on" echo " the first hard disk and activate this partition." echo return 1 fi echo "===> The BIOS will boot the first active partition $bios_boot." Check_LILO $bios_boot if [ $? -eq 0 -a "$ANSWER" = "LILO" ]; then echo "===> $bios_boot seems to contain a LILO boot manager." else # check for DOSC if [ "$bios_boot" = "`sysinfo --tag -C DOSC --partition`" ]; then echo "===> $bios_boot seems to contain a DOS boot loader." # check for OS/2 Bootmanager elif [ "$bios_boot" = "`sysinfo --tag -C Bootmanager --partition | fgrep -x $bios_boot`" ]; then echo "===> $bios_boot seems to contain a OS/2 boot manager." # check for BSD Bootmanager elif [ "$bios_boot" = "`sysinfo --tag -C BSD --partition | fgrep -x $bios_boot`" ]; then echo "===> $bios_boot seems to contain a BSD boot manager." # check for Solaris Bootmanager elif [ "$bios_boot" = "`sysinfo --tag -C Solaris --partition | fgrep -x $bios_boot`" ]; then echo "===> $bios_boot seems to contain a Solaris boot manager." else echo "===> $bios_boot seems to contain no (or an unknown) boot manager." fi fi echo return 0 } Do_Activate_Partition() { local dummy= local hd_dev= local hd_part= local f_name=Do_Activate_Partition local f_args=1 # (partition) -> Check_Args $f_name $f_args $# "$@" || return 255 hd_dev=`echo "$1" | cut -c 1-8` if [ "$hd_dev" = "/dev/rd/" ]; then hd_dev=`echo "$1" | cut -c 1-12` hd_part=`echo "$1" | cut -c 14-` elif [ "$hd_dev" = "/dev/ida" ]; then hd_dev=`echo "$1" | cut -c 1-13` hd_part=`echo "$1" | cut -c 15-` else hd_part=`echo "$1" | cut -c 9-` fi dummy="$hd_dev $hd_part" #Info ":INFO_ACTIVATING_PARTITION:" activate $dummy 2> $FILE_TMP_ERR if [ $? -eq 0 ]; then Msg ":INFO_ACTIVATE_SUCCESS:" else Error --file $FILE_TMP_ERR "$1 ; :ERR_ACTIVATE_PROBLEMS:" return 1 fi return 0 } Do_Install_LILO() { local lilo_cmd if Is_SPARC ; then lilo_cmd=silo else lilo_cmd=lilo fi Info ":INFO_LILO_RUNNING:" if [ "$DIR_TARGET" != "/" ]; then ( cd $DIR_TARGET; chroot $DIR_TARGET sbin/$lilo_cmd && echo "LILO ok" ) > $DIR_TARGET/tmp/lilo.error 2>&1 mv $DIR_TARGET/tmp/lilo.error $FILE_TMP_ERR # $lilo_cmd -r $DIR_TARGET > $FILE_TMP_ERR 2>&1 else ( /sbin/$lilo_cmd && echo "LILO ok" ) > $FILE_TMP_ERR 2>&1 fi if [ -z "`fgrep -x 'LILO ok' $FILE_TMP_ERR`" ]; then Error --file $FILE_TMP_ERR ":ERR_LILO_PROBLEMS:" return 1 else $CMD_BOX --nobutton --msg ":INFO_LILO_SUCCESS:" fi return 0 } Do_Add_LILO_Table() { local table= local partnum= table="`echo $1 | cut -c 1-8`" if [ -n "$table" ]; then partnum="`echo $1 | cut -c 9-`" if [ $partnum -lt 5 ]; then echo " table = $table" >> $DIR_TARGET/$FILE_LILO_CONF.tmp fi if ! Is_SPARC ; then echo " loader = /boot/chain.b" >> $DIR_TARGET/$FILE_LILO_CONF.tmp fi fi } Ask_LILO_Label() { local label= local partid= echo "$1" | fgrep '/dev/' > /dev/null if [ $? -eq 0 ]; then label="`echo $1 | cut -c 6-`" partid="`Get_Partition_Info --id $1`" case $partid in 1|4|6|11|12|14) label="dos" ;; 10) label="os2" ;; 130) label="solaris" ;; 131) label="lilo-$label" ;; 165) label="bsd" ;; 169) label="NetBSD" ;; esac else # propose "linux" as label if it looks like our kernel if [ -n "`echo $1 | sed -n '/^\/boot\/vmlinuz/p'`" ]; then label="linux" elif [ "$1" = "/vmlinuz" ]; then label="linux" fi fi sed -n '/label[ ]*=/s/^.*label[ ]*=[ ]*\(.*\)$/\1/p' $DIR_TARGET/$FILE_LILO_CONF.tmp | fgrep -x $label > /dev/null if [ $? -eq 0 ]; then label= fi while [ 1 ]; do Ask_String LILO_LABEL "$label" || return 1 if [ -z "$ANSWER" ]; then continue fi label="$ANSWER" # CHECK: test whether label already exists sed -n '/label[ ]*=/s/^.*label[ ]*=[ ]*\(.*\)$/\1/p' $DIR_TARGET/$FILE_LILO_CONF.tmp | fgrep -x $label > /dev/null if [ $? -eq 0 ]; then Warn ":WARN_LABEL_ALREADY_USED:" continue else cat << EOF >> $DIR_TARGET/$FILE_LILO_CONF.tmp label = $label EOF return 0 fi done } Ask_LILO_Params() { local append="$1" Debug "append = <$append>" # remove quotes from any previous append string append="`echo $append | cut -d'\"' -f 2`" Debug "append = <$append>" Ask_String LILO_PARAMS "$append" || return 1 if [ -n "$ANSWER" ]; then echo " append = \"$ANSWER\"" >> $DIR_TARGET/$FILE_LILO_CONF.tmp fi return 0 } Ask_LILO_Initrd() { local initrd_file=/boot/initrd.gz if [ ! -f $DIR_TARGET/$initrd_file ]; then initrd_file= ANSWER= return 0 fi Ask_String LILO_INITRD "$initrd_file" || return 1 return 0 } Ask_LILO_Entry() { local build_function="$1" local text_label="$2" local root_part="$3" local image= local entry=image local label= local use_initrd= local append= Choose --build "$build_function $DIR_TARGET" $text_label || return 1 if [ "$ANSWER" = "END" ]; then return 0 fi image="$ANSWER" echo "$image" | fgrep '/dev/' > /dev/null if [ $? -eq 0 ]; then entry=other cat << EOF >> $DIR_TARGET/$FILE_LILO_CONF.tmp $entry = $image EOF Ask_LILO_Label $image || continue Do_Add_LILO_Table $image else entry=image cat << EOF >> $DIR_TARGET/$FILE_LILO_CONF.tmp $entry = $image EOF Ask_LILO_Initrd || continue if [ -n "$ANSWER" ]; then echo " initrd = \"$ANSWER\"" >> $DIR_TARGET/$FILE_LILO_CONF.tmp use_initrd=true # on newer kernels we don't need this any more #append="load_ramdisk=1 ramdisk_size=2880" append="" else append="" fi Ask_LILO_Label $image || continue cat << EOF >> $DIR_TARGET/$FILE_LILO_CONF.tmp root = $root_part read-only EOF Ask_LILO_Params "$append" fi return 0 } Menu_Config_GRUB_HD() { local root_part # get root partition if [ "$DIR_TARGET" != "/" ]; then root_part="$CONF_INSTALL_ROOT" else root_part="`rdev | cut -d' ' -f 1`" fi Do_Store CONF_INSTALL_ROOT "$root_part" Do_Store CONF_INSTALL_LILO "$root_part" return 0 } Menu_Config_LILO_HD() { local default_mbr= local default_target= local lilo_in_mbr= local mode= local os2_bootmgr= local root_part= local root_part_id= local root_part_type= local target= # FIXME: shortcut in case we use GRUB if [ -x $DIR_TARGET/usr/sbin/grub ]; then Menu_Config_GRUB_HD return 0 fi Do_Analyse_Boot_Setup > $DIR_LST_TMP/bootsetup Browse2 $DIR_LST_TMP/bootsetup ANALYSE_BOOT_SETUP || return 1 # -- outermost loop start -- while [ 1 ]; do # -- target loop start -- (not indended) while [ 1 ]; do # get first mbr default_mbr="`sysinfo --tag -C MBR --disk`" Debug "default_mbr = <$default_mbr>" # get root partition if [ "$DIR_TARGET" != "/" ]; then root_part="$CONF_INSTALL_ROOT" else root_part="`rdev | cut -d' ' -f 1`" fi Debug "root_part = <$root_part>" # get root partition type root_part_id="`Get_Partition_Info --id $root_part`" Debug "root_part_id = <$root_part_id>" case $partid in 1|4|6|11|12|14) root_part_type=msdos ;; 131) root_part_type=ext2 ;; esac Debug "root_part_type = <$root_part_type>" # check MBR for LILO Check_LILO if [ $? -eq 0 -a "$ANSWER" = "LILO" ]; then lilo_in_mbr=true Debug "detected LILO in $default_mbr" fi # check for OS/2 boot manager os2_bootmgr="`sysinfo --tag -C Bootmanager --partition | sed -n '1p'`" if [ -n "$os2_bootmgr" ]; then Debug "detected OS/2 Bootmanager in $os2_bootmgr" fi # try to offer a smart default target default_target="`Get_Val CONF_INSTALL_LILO`" if [ -z "$default_target" ]; then if [ -n "$lilo_in_mbr" ]; then # bad idea to use the MBR, but if they are used to it... default_target="$default_mbr" else # use root partition per default default_target="$root_part" # use other partition if root is MSDOS if [ "$root_part_type" = "msdos" ]; then default_target=OTHER # do not allow LILO on msdos partitions Msg ":INFO_NO_LILO_ON_UMSDOS:" else # check if root_part is a primary partition on 1st disk if [ -z "`sysinfo --tag -C LILOACTIVE --partition | fgrep -x $root_part`" ]; then # without OS/2 bootmanager use the MBR if [ -z "$os2_bootmgr" ]; then default_target="$default_mbr" fi fi fi fi fi Debug "default_target = <$default_target>" Choose --build "Build_LILO_TARGET $root_part $root_part_type" LILO_TARGET $default_target || return 1 target="$ANSWER" case $target in /dev/hda|/dev/sda) mode=MBR ;; $root_part) mode=ROOT ;; OTHER) mode=OTHER Choose --build "Build_LILO_TARGET_OTHER $root_part" LILO_TARGET_OTHER || continue target="$ANSWER" ;; /dev/fd0H1440|/dev/fd0) mode=FLOPPY ;; NONE) return 0 ;; esac # BEGIN: sanity checks if [ "$mode" = "MBR" -o "$mode" = "FLOPPY" ]; then break fi # warn if a LILO is detected in the MBR if [ -n "$lilo_in_mbr" ]; then Warn ":WARN_LILO_FOUND_IN_MBR:" || continue fi break # END: sanity checks # -- target loop end -- done # -- default entry loop start -- while [ 1 ]; do again=true Do_Create_Generic_LILO_Conf $target Ask_LILO_Entry Build_LILO_ENTRY LILO_DEFAULT_ENTRY $root_part || break again= break # -- default loop end -- done if [ -n "$again" ]; then continue fi cat << EOF >> $DIR_TARGET/$FILE_LILO_CONF.tmp # # additional entries # EOF # -- alternate loop start -- while [ 1 ]; do again=true Ask_LILO_Entry Build_LILO_ADD_ENTRY LILO_ADD_ENTRY $root_part || break if [ "$ANSWER" = "END" ]; then again= break fi # -- alternate loop end -- done if [ -n "$again" ]; then continue fi Browse2 $DIR_TARGET/$FILE_LILO_CONF.tmp LILO_CONF || continue Ask_Bool INSTALL_LILO || continue if [ "$ANSWER" != "0" ]; then continue fi cp -a $DIR_TARGET/$FILE_LILO_CONF.tmp $DIR_TARGET/$FILE_LILO_CONF || continue if Is_SPARC ; then cp -a $DIR_TARGET/$FILE_LILO_CONF $DIR_TARGET/etc/silo.conf fi Do_Install_LILO || continue if [ "$mode" = "MBR" -o "$mode" = "FLOPPY" ]; then break fi # warn if target is no primary on 1st disk and no OS/2 Bootmanager if [ -z "`sysinfo --tag -C LILOACTIVE --partition | fgrep -x $target`" -a -z "$os2_bootmgr" ]; then Warn ":WARN_LILO_NOT_ACTIVE_AND_NO_BOOTMANAGER:" || continue else if [ -z "`sysinfo --tag -C active --partition | fgrep -x $target`" ]; then Ask_Bool --pretext "$target ; " ACTIVATE_PARTITION || continue if [ "$ANSWER" = "0" ]; then Do_Activate_Partition $target || continue else Warn ":WARN_LILO_NOT_ACTIVE:" || continue fi fi fi break done # -- outermost loop end -- Do_Store CONF_INSTALL_LILO "$target" return 0 } Menu_Config_Boot() { mount | fgrep ' / ' | fgrep umsdos > /dev/null if [ $? -eq 0 ]; then Msg ":INFO_NO_LILO_ON_UMSDOS:" return 1 fi while [ 1 ]; do $CMD_BOX --help ":MENU_CONFIG_BOOT_HELP:" \ --title ":MENU_CONFIG_BOOT_TITLE:" \ --menu ":MENU_CONFIG_BOOT_TEXT:" \ "Menu_Config_LILO_HD" ":MENU_CONFIG_LILO_HD:" 2> $FILE_TMP_ANSWER || return 1 COMMAND="`cat $FILE_TMP_ANSWER`" $COMMAND done } # libLSTbox - box call library shared between several scripts # # Copyright (C) 1993-1997 Ralf Flaxa, LST Software GmbH, Erlangen, Germany # # Ask what goal build_function Ask() { FUNC_NAME=Ask local cmd=$FILE_TMP_COMMAND local what="$1" local goal="$2" local ans=/tmp/LST/ans local prefix= local defval= echo "$FUNC_NAME $@" >> $FILE_DEBUG_TRACE shift 2 if [ "X$1" = "X--default" ]; then defval="$2" shift 2 fi case $what in bool|string) prefix=ASK defval="$1" ;; one) prefix=CHOOSE ;; menu) prefix=MENU what=one ;; esac cat << EOF > $cmd #!/bin/sh $CMD_BOX --title ":${prefix}_${goal}_TITLE:" \\ --help ":${prefix}_${goal}_HELP:" \\ --default "${defval}" \\ --${what} ":${prefix}_${goal}_TEXT:" \\ EOF case $what in one) $@ >> $cmd ;; esac echo "2> $ans" >> $cmd chmod 755 $cmd # log command if requested Log_Cmd $cmd || return 1 export ANSWER="`cat $ans`" return 0 } # # libLSTnew # # Ask what goal build_function Ask2() { FUNC_NAME=Ask local cmd=$FILE_TMP_COMMAND local what="$1" local goal="$2" local ans=$FILE_TMP_ANSWER local prefix= local defval= local other= local pretext= local posttext= echo "$FUNC_NAME $@" >> $FILE_DEBUG_TRACE shift 2 while [ 1 ]; do if [ $# -eq 0 ]; then break fi if [ "X$1" = "X--other" ]; then other=true shift 1 elif [ "X$1" = "X--default" ]; then defval="$2" shift 2 elif [ "X$1" = "X--pretext" ]; then pretext="$2" shift 2 elif [ "X$1" = "X--posttext" ]; then posttext="$2" shift 2 else break fi done case $what in bool|string) prefix=ASK if [ -z "$defval" ]; then defval="$1" fi ;; one) prefix=CHOOSE ;; menu) prefix=MENU what=one ;; esac if [ "$what" = "one" ]; then rm -f ${cmd}.itm $@ > ${cmd}.itm if [ ! -s ${cmd}.itm ]; then Debug "Error: empty list: $@" what=string prefix=ASK fi fi cat << EOF > $cmd #!/bin/sh $CMD_BOX --title ":${prefix}_${goal}_TITLE:" \\ --help ":${prefix}_${goal}_HELP:" \\ --default "${defval}" \\ --${what} "${pretext}:${prefix}_${goal}_TEXT:${posttext}" \\ EOF if [ "$what" = "one" ]; then if [ "$other" = "true" ]; then echo "\"OTHER\" \":${prefix}_${goal}_OTHER:\" \\" >> ${cmd} fi if [ "$none" = "true" ]; then echo "\"NONE\" \":${prefix}_${goal}_NONE:\" \\" >> ${cmd} fi cat ${cmd}.itm >> ${cmd} fi echo "2> $ans" >> $cmd chmod 755 $cmd # log command if requested Log_Cmd $cmd || return 1 export ANSWER="`cat $ans`" return 0 } Get_Module_Line() { sed -n "/^%[^%]*%$2%/p" $1 } Get_Module_Param_Num() { Get_Module_Line $1 $2 | cut -d'%' -f $NUM_POS } List_Param_Of_Module() { local num local i=0 local pos="`do_calc $NUM_POS + 1`" num="`Get_Module_Param_Num $1 $2`" if [ -z "$num" -o "$num" = '?' ]; then num=unknown Debug 'Number of insmod parameters is unknown !' return 1 elif [ "$num" = "0" ]; then num=none Debug "No insmod params." return 0 fi while [ 1 ]; do i="`do_calc $i + 1`" if [ $i -gt $num ]; then break fi parm="`Get_Module_Line $1 $2 | cut -d'%' -f $pos`" echo "$parm" pos="`do_calc $pos + $NUM_PER_PARAM`" done } Build_Param_Of_Module() { local params local val local i params="`List_Param_Of_Module $1 $2`" if [ $? -ne 0 ]; then return 1 fi if [ -z "$params" ]; then return 0 fi echo "\"DONE\" \":CHOOSE_PARAM_OF_MODULE_DONE:\" \\" echo "\"OTHER\" \":CHOOSE_PARAM_OF_MODULE_OTHER:\" \\" for i in $params ; do val="`get_val -f $FILE_VALUES_SEL Value_Of_Param%${2}%${i}%current`" echo "\"$i\" \"$i [${val}]\" \\" done } Build_Value_Of_Param() { local num local i=0 local pos="`do_calc $NUM_POS + 1`" local posvals local posdef local values local defval local val num="`Get_Module_Param_Num $1 $2`" if [ -z "$num" -o "$num" = '?' ]; then num=unknown Debug 'Number of insmod parameters is unknown !' return 1 elif [ "$num" = "0" ]; then num=none Debug "No insmod params." return 0 fi Debug "num = $num" while [ 1 ]; do i="`do_calc $i + 1`" if [ $i -gt $num ]; then Debug "param $3 not found." break fi parm="`Get_Module_Line $1 $2 | cut -d'%' -f $pos`" if [ "$parm" != "$3" ]; then pos="`do_calc $pos + $NUM_PER_PARAM`" continue fi posvals="`do_calc $pos + 2`" Debug "posvals = <$posvals>" posdef="`do_calc $pos + 3`" Debug "posdef = <$posdef>" values="`Get_Module_Line $1 $2 | cut -d'%' -f $posvals | sed 's/,/ /g'`" Debug "values = <$values>" defval="`Get_Module_Line $1 $2 | cut -d'%' -f $posdef`" Debug "defval = <$defval>" for val in $values ; do if [ "X$val" = "X$defval" ]; then echo "\"$val\" \"$val [default]\" \\" else echo "\"$val\" \"$val\" \\" fi done break done } Choose_Param_Of_Module() { local modname="$1" local modparam shift 1 if [ $# -gt 0 ]; then modparam="$1" else modparam="`get_val -f $FILE_VALUES_SEL Param_Of_Module%${modname}%current`" fi Ask2 one PARAM_OF_MODULE --pretext "module=$modname ; ; " --default "$modparam" Build_Param_Of_Module $FILE_MODULES_DATA $modname || return 1 modparam="$ANSWER" set_val -f $FILE_VALUES_SEL Param_Of_Module%${modname}%current "${modparam}" return 0 } Choose_Value_Of_Param() { local modname="$1" local modparam="$2" local paramval shift 2 if [ $# -gt 0 ]; then paramval="$1" else paramval="`get_val -f $FILE_VALUES_SEL Value_Of_Param%${modname}%${modparam}%current`" fi Ask2 one VALUE_OF_PARAM --other --pretext "module=$modname ; parameter=$modparam ; ; " --default "$paramval" Build_Value_Of_Param $FILE_MODULES_DATA $modname $modparam || return 1 paramval="$ANSWER" if [ "$paramval" = "OTHER" ]; then paramval="`get_val -f $FILE_VALUES_SEL Value_Of_Param%${modname}%${modparam}%current`" Ask2 string MODULE_PARAM --other --pretext "module=$modname ; parameter=$modparam ; ; " --default "$paramval" || return 1 paramval="$ANSWER" fi set_val -f $FILE_VALUES_SEL Value_Of_Param%${modname}%${modparam}%current "${paramval}" return 0 } Ask_Module_Param() { local modname="$1" local params local insmod_params="`get_val -f $FILE_VALUES_SEL Module_Params%${modname}%current`" Ask2 string MODULE_PARAM "$insmod_params" || return 1 insmod_params="$ANSWER" set_val -f $FILE_VALUES_SEL Module_Params%${modname}%current "${insmod_params}" return 0 } Menu_Module_Param() { local modname="$1" local modparam local paramval local params local insmod_params params="`List_Param_Of_Module $FILE_MODULES_DATA $modname`" if [ -z "$params" ]; then Ask_Module_Param $modname || return 1 insmod_params="$ANSWER" else while [ 1 ]; do Choose_Param_Of_Module "$modname" || return 1 modparam="$ANSWER" if [ "$modparam" = "OTHER" ]; then Ask_Module_Param $modname || continue insmod_params="$ANSWER" break fi if [ "$modparam" != "DONE" ]; then Choose_Value_Of_Param "$modname" "$modparam" || continue paramval="$ANSWER" else insmod_params= for modparam in `List_Param_Of_Module $FILE_MODULES_DATA $modname` ; do paramval="`get_val -f $FILE_VALUES_SEL Value_Of_Param%${modname}%${modparam}%current`" if [ -n "$paramval" ]; then insmod_params="$insmod_params $modparam=${paramval}" fi done break fi done fi ANSWER="$insmod_params" return 0 } # Ask_Bool ( [--pretext PRETEXT] [--prehelp PREHELP] [--help ALTERNATE_HELP] [--text ALTERNATE_TEXT] VARNAME [DEFAULTVAL] ) # # Just ask a yes/no question # Ask_Bool() { FUNC_NAME=Ask_Bool export ANSWER= local retval= local help= local text= local prehelp= local pretext= echo "$FUNC_NAME $@" >> $FILE_DEBUG_TRACE if [ $# -lt 1 ]; then Panic "got $# instead of at least 1 arg!" fi # look for pretext if [ $# -gt 2 ]; then if [ "$1" = '--pretext' ]; then pretext="$2" shift 2 fi fi # look for prehelp if [ $# -gt 2 ]; then if [ "$1" = '--prehelp' ]; then prehelp="$2" shift 2 fi fi # look for alternate help if [ $# -gt 2 ]; then if [ "$1" = '--help' ]; then help="$2" shift 2 fi fi # look for alternate text if [ $# -gt 2 ]; then if [ "$1" = '--text' ]; then text="$2" shift 2 fi fi if [ -z "$help" ]; then help=":ASK_$1_HELP:" fi if [ -z "$text" ]; then text=":ASK_$1_TEXT:" fi # build command header echo "$CMD_BOX --help \"${prehelp}${help}\" --title \":ASK_$1_TITLE:\" --bool \"${pretext}${text}\" \\" > $FILE_TMP_COMMAND # append default value if available if [ $# -gt 1 ]; then echo "--default \"$2\" \\" >> $FILE_TMP_COMMAND fi # build command trailer echo "2> $FILE_TMP_ANSWER" >> $FILE_TMP_COMMAND chmod 755 $FILE_TMP_COMMAND # log command if requested Log_Cmd # execute command sh $FILE_TMP_COMMAND retval=$? if [ $retval -eq 0 ]; then ANSWER="`cat $FILE_TMP_ANSWER`" fi rm -f $FILE_TMP_COMMAND rm -f $FILE_TMP_ANSWER return $retval } # Ask_String ( [--pretext PRETEXT] VARNAME [DEFAULTVAL] ) # # ask for a string # Ask_String() { FUNC_NAME=Ask_String export ANSWER= local retval= local text= local help= local pretext= local prehelp= echo "$FUNC_NAME $@" >> $FILE_DEBUG_TRACE if [ $# -lt 1 ]; then Panic "got $# instead of at least 1 arg!" fi if [ $# -gt 2 -a "$1" = '--pretext' ]; then pretext="$2" shift 2 fi if [ $# -gt 2 -a "$1" = '--prehelp' ]; then prehelp="$2" shift 2 fi if [ $# -gt 2 -a "$1" = '--help' ]; then help="$2" shift 2 else help=":ASK_$1_HELP:" fi text=":ASK_$1_TEXT:" # if [ $# -gt 1 ]; then # $CMD_BOX --default "$2" --help "${prehelp}${help}" --title ":ASK_$1_TITLE:" --string "${pretext}${text}" 2> $FILE_TMP_ANSWER # else # $CMD_BOX --help "${prehelp}${help}" --title ":ASK_$1_TITLE:" --string "${pretext}${text}" 2> $FILE_TMP_ANSWER # fi # retval=$? # build command header echo "$CMD_BOX --help \"${prehelp}${help}\" --title \":ASK_$1_TITLE:\" --string \"${pretext}${text}\" \\" > $FILE_TMP_COMMAND # append default value if available if [ $# -gt 1 ]; then echo "--default \"$2\" \\" >> $FILE_TMP_COMMAND fi # build command trailer echo "2> $FILE_TMP_ANSWER" >> $FILE_TMP_COMMAND chmod 755 $FILE_TMP_COMMAND # log command if requested Log_Cmd # execute command sh $FILE_TMP_COMMAND retval=$? if [ $retval -eq 0 ]; then ANSWER="`cat $FILE_TMP_ANSWER`" else ANSWER="" Debug -D "Ask_String Output (Start)" Debug -c cat $FILE_TMP_ANSWER Debug -D "Ask_String Output (End)" fi rm -f $FILE_TMP_ANSWER return $retval } # Box ( TYPE [--var VAR] [--help HELP] [--text TEXT] [--title TITLE]) # [--build ITMEMBUILDFUNCTION] [DEFAULTVAL]) # # Box is a box frontend, returning answer in $ANSWER # # box-types (TYPE): # # a) input boxes # bool # num # ip # string # one # menu # showlist # menulist # # b) output boxes # info # msg # browse # err # warn # # --var ask & set value of variable VAR # --help replace standard-help with HELP # --text replace standard-text with TEXT # --title replace standard-title with TITLE # --build use function BUILD to create itemlist # Box() { FUNC_NAME=Box export ANSWER= local box_type=string local retval= local variable=BOX local title= local text= local help= local build= local defval= local file= echo "$FUNC_NAME $@" >> $FILE_DEBUG_TRACE # process options if [ $# -eq 0 ]; then Panic "$FUNC_NAME: panic! no box type specified!" fi # get box_type box_type="$1" shift 1 case $box_type in bool) prefix=BOOL ;; num|ip|string) prefix=ASK ;; one|showlist) prefix=CHOOSE ;; menu|sumlist) prefix=MENU ;; msg|info|browse) prefix=INFO ;; err) box_type=browse prefix=ERR ;; warn) box_type=msg prefix=WARN ;; *) Panic "$FUNC_NAME: panic! invalid box type specified!";; esac # set standard help title=":${prefix}_${variable}_TITLE:" text=":${prefix}_${variable}_TEXT:" help=":${prefix}_${variable}_HELP:" while [ 1 ]; do if [ $# -eq 0 ]; then break elif [ $# -gt 1 ]; then # options that take arguments case $1 in --var) variable="$2" title=":${prefix}_${variable}_TITLE:" text=":${prefix}_${variable}_TEXT:" help=":${prefix}_${variable}_HELP:" shift 2 continue;; --help) help="$2" shift 2 continue;; --title) title="$2" shift 2 continue;; --text) text="$2" shift 2 continue;; --build) build="$2" shift 2 continue;; esac else # flags that take no arguments if [ $# -eq 1 ]; then # last argument is a default value or a file to browse if [ "$box_type" = "browse" ]; then file="$1" shift 1 continue else defval="$1" shift 1 continue fi fi fi Panic "$FUNC_NAME: panic! invalid arguments $* !" done # command header echo -n "$CMD_BOX " > $FILE_TMP_COMMAND # command options if [ -n "$help" ]; then echo "--help \"$help\" \\" >> $FILE_TMP_COMMAND fi if [ -n "$title" ]; then echo "--title \"$title\" \\" >> $FILE_TMP_COMMAND fi if [ "$box_type" = "browse" ]; then echo "--text \"$text\" \\" >> $FILE_TMP_COMMAND echo "--browse $file \\" >> $FILE_TMP_COMMAND else echo "--$box_type \"$text\" \\" >> $FILE_TMP_COMMAND fi if [ -n "$defval" ]; then echo "--default \"$defval\" \\" >> $FILE_TMP_COMMAND fi # command items if [ -n "$build" ]; then # call build-function to build menu items $build > $FILE_TMP_MSG if [ -s $FILE_TMP_MSG ]; then cat $FILE_TMP_MSG >> $FILE_TMP_COMMAND rm -f $FILE_TMP_MSG else rm -f $FILE_TMP_COMMAND rm -f $FILE_TMP_ANSWER Panic "$FUNC_NAME: panic! empty list of items!" fi fi # command trailer echo "2> $FILE_TMP_ANSWER" >> $FILE_TMP_COMMAND chmod 755 $FILE_TMP_COMMAND # log command if requested Log_Cmd # execute command sh $FILE_TMP_COMMAND retval=$? if [ "$box_type" = "info" ]; then sleep 1 fi if [ $retval -eq 0 ]; then if [ "$box_type" != "sumlist" ]; then ANSWER="`cat $FILE_TMP_ANSWER`" rm -f $FILE_TMP_ANSWER fi fi rm -f $FILE_TMP_COMMAND return $retval } Browse() { FUNC_NAME=Browse echo "$FUNC_NAME $@" >> $FILE_DEBUG_TRACE if [ $# -eq 2 ]; then Box browse --text "$2" $1 || return 1 return 0 else Box browse $1 || return 1 return 0 fi } Browse2() { FUNC_NAME=Browse2 echo "$FUNC_NAME $@" >> $FILE_DEBUG_TRACE Box browse --var "$2" $1 || return 1 return 0 } # Choose ( [--none] [--other] [--prefix PREFIX] [--menutitle MENUTITLE] [--build MENUBUILDFUNCTION] VARNAME [CONFVARNAME] ) # # ask for one out of many choices # Choose() { FUNC_NAME=Choose export ANSWER= local retval= local box_type=one local one_flag= local other_flag= local none_flag= local menu_title= local build_function= local confval= local defval= local prefix= echo "$FUNC_NAME $@" >> $FILE_DEBUG_TRACE while [ 1 ]; do if [ $# -gt 1 ]; then case $1 in --build) build_function="$2" shift 2 continue;; --default) defval="$2" shift 2 continue;; --menutitle) menu_title="$2" shift 2 continue;; --prefix) prefix="$2" shift 2 continue;; --none) none_flag=true shift 1 continue;; --other) other_flag=true shift 1 continue;; --menu) box_type=menu shift 1 continue;; --multi) box_type=multi shift 1 continue;; --sumlist) box_type=sumlist shift 1 continue;; --onelist) box_type=sumlist one_flag='-O' shift 1 continue;; --showlist) box_type=showlist shift 1 continue;; *) break;; esac else break fi done if [ $# -lt 1 ]; then Panic "got $# instead of at least 1 args!" fi # build command header if [ -z "$prefix" ]; then case $box_type in one|showlist) prefix=CHOOSE ;; menu|sumlist|multi) prefix=MENU ;; esac fi echo "$CMD_BOX $one_flag --help \":${prefix}_$1_HELP:\" \\" > $FILE_TMP_COMMAND echo "--title \":${prefix}_$1_TITLE:\" \\" >> $FILE_TMP_COMMAND echo "--$box_type \":${prefix}_$1_TEXT:\" \\" >> $FILE_TMP_COMMAND # append default value if available if [ $# -gt 1 ]; then confval="`Get_Val $2`" if [ -n "$confval" ]; then echo "--default \"$confval\" \\" >> $FILE_TMP_COMMAND else echo "--default \"$2\" \\" >> $FILE_TMP_COMMAND fi elif [ -n "$defval" ]; then echo "--default \"$defval\" \\" >> $FILE_TMP_COMMAND fi if [ -n "$menu_title" ]; then echo "--menutitle \"$menu_title\" \\" >> $FILE_TMP_COMMAND fi rm -f $FILE_TMP_MSG if [ -n "$none_flag" ]; then Debug "NONE item allowed" echo "\"\" \":TYPE_$1_NONE:\" \\" >> $FILE_TMP_MSG fi if [ -n "$other_flag" ]; then Debug "OTHER item allowed" Is_Expert && echo "\"other\" \":DEVICE_DIRECT:\" \\" >> $FILE_TMP_MSG fi # build command header if [ -z "$build_function" ]; then build_function="List box $1" fi Debug "build item list with <$build_function>" # call build-function to build menu items $build_function >> $FILE_TMP_MSG if [ $? -ne 0 ]; then Debug "Error: return val != 0" Debug "Error: $ERROR" Error "$ERROR" return 1 fi if [ -s $FILE_TMP_MSG ]; then cat $FILE_TMP_MSG >> $FILE_TMP_COMMAND rm -f $FILE_TMP_MSG else Debug "empty list. responsible command was" Debug -c cat $FILE_TMP_COMMAND Error ":ERR_EMPTY_SELECTLIST:" return 1 fi # build command trailer echo "2> $FILE_TMP_ANSWER" >> $FILE_TMP_COMMAND chmod 755 $FILE_TMP_COMMAND # log command if requested Log_Cmd # execute command Debug "Executing command: 'sh $FILE_TMP_COMMAND'" Debug -D "----- $FILE_TMP_COMMAND" Debug -c cat $FILE_TMP_COMMAND Debug -D "----- " sh $FILE_TMP_COMMAND retval=$? Debug "retval is $retval" if [ $retval -eq 0 ]; then ANSWER="`cat $FILE_TMP_ANSWER`" case $box_type in one) if [ "$ANSWER" = "other" ]; then Ask_String $1 $confval retval=$? # ANSWER is set by Ask_String fi rm -f $FILE_TMP_ANSWER ;; menu|onelist|showlist) rm -f $FILE_TMP_ANSWER ;; sumlist|multi) # do not set ANSWER but keep $FILE_TMP_ANSWER ;; esac fi rm -f $FILE_TMP_COMMAND return $retval } Info() { FUNC_NAME=Info echo "$FUNC_NAME $@" >> $FILE_DEBUG_TRACE Box info --text "$@" || return 1 return 0 } Info_lite() { FUNC_NAME=Info_lite echo "$FUNC_NAME $@" >> $FILE_DEBUG_TRACE $CMD_BOX --info "$@" || return 1 sleep 1 return 0 } List() { local CD_DEV_LIST="aztcd cdu31a cdu535 cm206cd gscd mcd mcdx optcd sbpcd scd0 scd1 sjcd hda hdb hdc hdd arcd bpcd bpmcd dscd eicd epcd kicd oicd pwcd" local CUA_LIST="cua0 cua1 cua2 cua3" local FLOPPY_DEV_LIST="E2880 H1440 H720 D720 H360 D360 h1200 h720 h360 d360" local KERNTZ_LIST="UTCTIME LOCALTIME" local NIS_LIST="CLIENT SERVER" local PARALLEL_DEV_LIST="lp0 lp1 lp2" local USB_PRINTER_DEV_LIST="lp0 lp1 lp2" # all possibles gs devices # local PRINTER_LIST="apple bj10e bj200 lbp8 m8510 la50 la75 declj250 lj250 ln03 epson eps9high epsonc escp2 cdeskjet cdjcolor cdjmono deskjet djet500 djet500c cdj550 laserjet ljet2p ljet3 ljet4 ljetplus paintjet pj pjxl pjxl300 jetp3852 ibmpro necp6 oki ricoh sparc t4693d2 t4693d4 t4693d8 t4695" # available devices in gs 2.6.2 # local PRINTER_LIST="bj10e bj200 cdeskjet cdjcolor cdjmono cdj550 djet500 djet500c ljet2p ljet3 ljet4 ljetplus paintjet epson escp2 necp6" # available devices in gs 3.33 local PRINTER_LIST="NET PostScript bj200 bj10e lbp8 m8510 la50 la75 declj250 ln03 eps9high epsonc epson stcolor cdjcolor djet500 djet500c cdj500 cdeskjet cdj550 laserjet ljet2p ljet3 ljet4 ljetplus cdjmono pjxl300 pjtest paintjet pjxltest ibmpro necp6 sparc t4693d2 t4693d4 t4693d8" local PRINTER_PAPER="A3 A4 A5 Letter Legal Ledger" local PRINTER_RES="75x75 150x150 180x180 180x360 300x300 360x360 400x400 600x600 720x720 800x800" local SERIAL_DEV_LIST="ttyS0 ttyS1 ttyS2 ttyS3" local SERIAL_SPEED_LIST="115200 57600 38400 19200 9600 2400 1200" local SHELL_LIST="sh bash ash csh tcsh pdksh zsh" local TAPE_DEV_LIST="st0 st1 tpqic11 tpqic24 ftape tpqic120 tpqic150" local TERM_LIST="linux linux-mono vt100" local TIMEZONE_LIST="Australia/ACT Australia/Adelaide Australia/Brisbane Australia/Broken_Hill Australia/Canberra Australia/Darwin Australia/Hobart Australia/LHI Australia/Lindeman Australia/Lord_Howe Australia/Melbourne Australia/NSW Australia/North Australia/Perth Australia/Queensland Australia/South Australia/Sydney Australia/Tasmania Australia/Victoria Australia/West Australia/Yancowinna Brazil/Acre Brazil/DeNoronha Brazil/East Brazil/West CET Canada/Atlantic Canada/Central Canada/East-Saskatchewan Canada/Eastern Canada/Mountain Canada/Newfoundland Canada/Pacific Canada/Saskatchewan Canada/Yukon Chile/Continental Chile/EasterIsland Cuba EET Egypt Factory GB Eire GMT GMT+0 GMT+1 GMT+10 GMT+11 GMT+12 GMT+13 GMT+2 GMT+3 GMT+4 GMT+5 GMT+6 GMT+7 GMT+8 GMT+9 GMT-0 GMT-1 GMT-10 GMT-11 GMT-12 GMT-2 GMT-3 GMT-4 GMT-5 GMT-6 GMT-7 GMT-8 GMT-9 GMT0 GMT1 GMT10 GMT11 GMT12 GMT13 GMT2 GMT3 GMT4 GMT5 GMT6 GMT7 GMT8 GMT9 Greenwich Hongkong Iceland Iran Israel Jamaica Japan Libya MET Mexico/BajaNorte Mexico/BajaSur Mexico/General NZ Navajo PRC Poland ROC ROK Singapore SystemV/AST4 SystemV/AST4ADT SystemV/CST6 SystemV/CST6CDT SystemV/EST5 SystemV/EST5EDT SystemV/HST10 SystemV/MST7 SystemV/MST7MDT SystemV/PST8 SystemV/PST8PDT SystemV/YST9 SystemV/YST9YDT Turkey UCT US/Alaska US/Aleutian US/Arizona US/Central US/East-Indiana US/Eastern US/Hawaii US/Michigan US/Mountain US/Pacific US/Pacific-New US/Samoa UTC Universal W-SU WET Zulu" local X_SERVER_LIST local tag_prefix= local label_prefix= local items= local current= local show_type=raw if Is_SPARC ; then X_SERVER_LIST="Xsun Xsun24 XsunMono" else X_SERVER_LIST="XFree86 XF86_FBDev XF86_SVGA XF86_VGA16 XF86_3DLabs XF86_IBM8514 XF86_AGX XF86_I128 XF86_Mach32 XF86_Mach64 XF86_Mach8 XF86_Mono XF86_P9000 XF86_S3 XF86_S3V XF86_W32 Xaccel Xmetro" fi if [ $# -gt 0 -a "$1" = "box" ]; then show_type=box shift 1 fi if [ $# -eq 0 ]; then Debug "no arg passed to List" Panic "List called without any arguments" return 1 fi case $1 in CD_DEV) items="$CD_DEV_LIST" tag_prefix="/dev/" label_prefix="TYPE_CD_" ;; FLOPPY_DEV) items="$FLOPPY_DEV_LIST" tag_prefix="/dev/fd$2" label_prefix="TYPE_FLOPPY_" ;; KERNTZ) items="$KERNTZ_LIST" tag_prefix="KTZ_" label_prefix="TYPE_KERNTZ_" ;; NIS) items="$NIS_LIST" tag_prefix="" label_prefix="TYPE_NIS_" ;; PARALLEL_DEV) items="$PARALLEL_DEV_LIST" tag_prefix="/dev/" label_prefix="TYPE_PARALLEL_DEV_" ;; USB_PRINTER_DEV) items="$USB_PRINTER_DEV_LIST" tag_prefix="/dev/usb/" label_prefix="TYPE_USB_PRINTER_DEV_" ;; PRINTER) items="$PRINTER_LIST" label_prefix="TYPE_PRINTER_" ;; PRINTER_PAPER) items="$PRINTER_PAPER" label_prefix="" ;; PRINTER_RES) items="$PRINTER_RES" label_prefix="" ;; SERIAL_SPEED) items="$SERIAL_SPEED_LIST" label_prefix="TYPE_SPEED_B" ;; SERIAL_DEV) items="$SERIAL_DEV_LIST" tag_prefix="/dev/" label_prefix="TYPE_SERIAL_DEV_" ;; SHELL) items="" for current in $SHELL_LIST; do if [ -f $DIR_TARGET/bin/$current ]; then items="$items $current" fi done tag_prefix="/bin/" label_prefix="TYPE_SHELL_" ;; TAPE_DEV) items="$TAPE_DEV_LIST" tag_prefix="/dev/" label_prefix="TYPE_TAPE_" ;; TERM) items="$TERM_LIST" label_prefix="TYPE_TERM_" ;; TIMEZONE) items="$TIMEZONE_LIST" label_prefix="" ;; X_SERVER) items="" for current in $X_SERVER_LIST; do if [ -f /usr/X11R6/bin/$current -o \ -f $DIR_TARGET/usr/X11R6/bin/$current ]; then items="$items $current" fi done label_prefix="TYPE_X_SERVER_" ;; *) Debug "fallback: calling from List old function <Build_$1>" Build_$1 return 0 ;; esac for current in $items ; do if [ "$show_type" = "raw" ]; then echo "${tag_prefix}${current} :${label_prefix}${current}:" elif [ "$show_type" = "box" ]; then if [ -n "$label_prefix" ]; then # FIXME: special handling for PostScript if [ "$current" = "PostScript" ]; then echo "\"${tag_prefix}${current}\" \"Local PostScript Printer\" \\" else echo "\"${tag_prefix}${current}\" \":${label_prefix}${current}:\" \\" fi else echo "\"${tag_prefix}${current}\" \"${current}\" \\" fi else echo "unsupported show_type <$show_type>" return 1 fi done return 0 } Msg() { FUNC_NAME=Msg echo "$FUNC_NAME $@" >> $FILE_DEBUG_TRACE Box msg --text "$@" || return 1 return 0 } Msg2() { FUNC_NAME=Msg2 echo "$FUNC_NAME $@" >> $FILE_DEBUG_TRACE Box msg --var "$1" || return 1 return 0 } # libLSTdebug - Debug functions shared between several scripts # # Copyright (C) 1993-1997 Ralf Flaxa, LST Software GmbH, Erlangen, Germany # Call_Direct() { local cmd local retval echo echo -n "please enter name of function to call: " read cmd History "`date` Call_Direct: calling <$cmd>" $cmd retval=$? History "`date` Call_Direct: command <$cmd> returned with <$retval>" echo echo "command <$cmd> returned with <$retval>" } Debug() { local screen=true local timestamp=true local command= local pipe= local disk_log= local permanent=$DIR_TARGET/var/adm/LST/log if [ "$MODE_DEBUG" != "true" ]; then return 0 fi if [ -d $permanent ]; then disk_log=$permanent/debug fi if [ "X$1" = "X-d" -o "X$1" = "X--diskonly" ]; then screen= shift fi if [ "X$1" = "X-n" -o "X$1" = "X--nostamp" ]; then timestamp= shift fi if [ "X$1" = "X-D" -o "X$1" = "X--disk-nostamp" ]; then screen= timestamp= shift fi if [ "X$1" = "X-c" -o "X$1" = "X--command" ]; then screen= timestamp= shift command="$*" fi if [ "X$1" = "X-p" -o "X$1" = "X--pipe" ]; then timestamp= pipe=true shift fi if [ -n "$command" -a -n "$disk_log" ]; then $command >> $disk_log 2>&1 return 0 fi if [ -n "$pipe" ]; then if [ -n "$disk_log" ]; then tee -a $disk_log >> $FILE_TMP_DEBUG else cat - >> $FILE_TMP_DEBUG fi return 0 fi if [ -n "$screen" ]; then echo "`date` debug: $@" >> $FILE_TMP_DEBUG fi if [ -z "$disk_log" ]; then return 0 fi if [ -n "$timestamp" ]; then echo "`date` debug: $@" >> $disk_log else echo "$@" >> $disk_log fi } Log_Cmd() { local num if [ -f /tmp/.log ]; then num="`cat /tmp/.log`" if [ -z "$num" ]; then num=0 fi num="`do_calc $num + 1`" echo "$num" > /tmp/.log cp -a $FILE_TMP_COMMAND /var/adm/LST/log/cmd.$num echo "debug: cmd $num saved to /var/adm/LST/log/cmd.$num" > /dev/tty5 echo "debug: calling cmd $num:" > /dev/tty5 fi } Debug_Stop() { local debug_ans echo "Debug_Stop called. Press <Enter> to continue." read debug_ans } # Do_Log ( [-d] [-n] [-f FILE] text_to_log ) # # Log a string for logging or postponed display # Should be usable instead of echo. # # Options: # -d delete file # -n do not append newline # -f FILE log to file FILE # Do_Log() { local deleteflag= local appendflag= local logfile=$FILE_TMP_LOG # parse loop while [ 1 ]; do if [ $# -gt 1 -a "X$1" = 'X-f' ]; then logfile=$2 shift 2 elif [ $# -gt 0 ]; then if [ "X$1" = 'X-d' ]; then deleteflag=true shift 1 elif [ "X$1" = 'X-n' ]; then appendflag=true shift 1 else # no more options, so the rest is message break fi fi done Debug --nostamp "$@" if [ -n "$deleteflag" ]; then rm -f "$logfile" fi if [ -n "$appendflag" ]; then echo -n "$@" >> $logfile else echo "$@" >> $logfile fi } Disable_Auto_Mode() { CMD_BOX="box" set_val -f /etc/lst.cnf CMD_BOX "box" MODE_QUERY="prompt" set_val MODE_QUERY prompt MODE_SPEED="normal" set_val MODE_SPEED normal return 0 } Error() { local error_help= local error_text= local error_file= echo -n "" # swvc 1 if [ $# -gt 1 -a "$1" = '--file' ]; then error_file="$2" shift 2 fi if [ $# -gt 1 -a "$1" = '--help' ]; then error_help="$2" shift 2 else error_help=":HELP_ERROR:" fi if [ $# -gt 0 ]; then error_text=":ERR_MSG_WAS: ; ; $@ ; " else error_text=":ERR_IS_UNKNOWN:" fi History "`date` error: $error_text" if [ -z "$error_file" ]; then $CMD_BOX --title ":ERROR:" --help "$error_help" --msg "$error_text" else if [ -s $error_file ]; then History "error log in $error_file:" History "`cat $error_file`" $CMD_BOX --title ":ERROR:" --help "$error_help" --text "$error_text" --browse $error_file rm -f $error_file else $CMD_BOX --title ":ERROR:" --help "$error_help" --msg "$error_text" fi fi Disable_Auto_Mode return 0 } Error2() { echo -n "" # swvc 1 echo "--------------------------------" >> $FILE_TMP_ERR History "`date` error: $@" History "`cat $FILE_TMP_ERR`" Disable_Auto_Mode Box err --var "$1" $FILE_TMP_ERR || return 1 return 0 } Err_Not_Available() { Error --help ":HELP_NOT_AVAILABLE:" ":INFO_NOT_AVAILABLE:" } Err_Not_Implemented() { Error --help ":HELP_NOT_IMPLEMENTED:" ":INFO_NOT_IMPLEMENTED:" } History() { Do_Log -f $FILE_LOG_HISTORY "$@" } History_Install() { History "`date` $LOGNAME: $PKG_NAME: $@" } Panic() { History "`date` panic: $@" echo echo "Panic!" echo "$@" echo while [ 1 ]; do echo -n "abort (a), continue (c), show var (v), set var (s), call function (f): " read ans if [ "$ans" = "a" ]; then History "`date` panic: abort and exit." reset exit 1 elif [ "$ans" = "v" ]; then History "`date` panic: continue with Show_Value." Show_Value elif [ "$ans" = "s" ]; then History "`date` panic: continue with Set_Value." Set_Value elif [ "$ans" = "f" ]; then History "`date` panic: continue with Call_Direct." Call_Direct elif [ "$ans" = "c" ]; then History "`date` panic: try to continue." return 0 fi done } Set_Value() { local var local value echo -n "enter name of variable to set: " read var echo -n "enter value of $var: " read value echo "export $var=\"$value\"" > /tmp/val . /tmp/val History "`date` Set_Value: value of <$var> set to <$value>" rm -f /tmp/val } Show_Value() { local var echo -n "enter name of variable to show: " read var eval "echo \"\$$var\"" > /tmp/val echo "$var=<`cat /tmp/val`>" History "`date` Show_Value: value of <$var> is <`cat /tmp/val`>" rm -f /tmp/val } Simulate() { $CMD_BOX --help ":MENU_SIMULATE_HELP:" --title ":MENU_SIMULATE_TITLE:" --msg ":MENU_SIMULATE_TEXT: ; ; $*" 2> /dev/null } Warn() { local warn_help= local warn_text= local warn_file= if [ $# -gt 1 -a "$1" = '--file' ]; then warn_file="$2" shift 2 fi if [ $# -gt 1 -a "$1" = '--help' ]; then warn_help="$2" shift 2 else warn_help=":HELP_WARNING:" fi if [ $# -gt 0 ]; then warn_text=":WARNING: ! ; ; $@ ; " else warn_text=":WARNING: !" fi History "`date` warn: $warn_text" if [ -z "$warn_file" ]; then $CMD_BOX --title ":WARNING:" --help "$warn_help" --msg "$warn_text" || return 1 else if [ -f $warn_file ]; then echo "--------------------------" >> $warn_file History "error log in $warn_file:" History "`cat $warn_file`" $CMD_BOX --title ":WARNING:" --help "$warn_help" --text "$warn_text" --browse $warn_file || return 1 rm -f $warn_file else $CMD_BOX --title ":WARNING:" --help "$warn_help" --msg "$warn_text" || return 1 fi fi return 0 } Warn2() { History "`date` warn: $1" Box warn --var "$1" || return 1 return 0 } # libLSTanalyse Write_Analyse_Infos() { local was_mounted= local extension=0 local rfile= local i mount | fgrep 'on /floppy' > /dev/null && was_mounted=true umount /floppy >/dev/null 2>&1 Msg ":DO_INSERT_DOS_FLOPPY:" || return 0 mount -t msdos /dev/fd0H1440 /floppy if [ $? -ne 0 ]; then Msg ":ERR_MOUNT_FLOPPY_FAILED:" else Info ":INFO_ANALYSE_RUNNING:" while [ 1 ]; do if [ ! -f /floppy/analyse.$extension ]; then break else extension="`do_calc $extension + 1`" fi done rfile="/floppy/analyse.$extension" echo "=== report from `sysinfo --version` ===" > $rfile sysinfo >> $rfile for i in /proc/interrupts /proc/ioports /proc/dma /proc/pci /proc/cpuinfo /proc/modules /proc/devices /proc/net/dev /var/adm/LST/analyse/boot.params /var/adm/LST/analyse/boot.msg ; do if [ -f $i ]; then echo "=== $i ===" >> $rfile cat $i >> $rfile fi done echo "=== current dmesg output at `date` ===" >> $rfile dmesg >> $rfile if [ $? -ne 0 ]; then Msg ":ERR_WRITE_FAILED:" else sync sync umount /floppy >/dev/null 2>&1 Msg "analyse.$extension ; :INFO_WRITE_SUCCEEDED:" fi fi while [ 1 ]; do umount /floppy >/dev/null 2>&1 if [ -z "$was_mounted" ]; then return 0 ; fi Msg ":DO_INSERT_MODULES_FLOPPY:" || return 1 mount -r /dev/fd0H1440 /floppy && break Msg ":ERR_MOUNT_FLOPPY_FAILED:" || return 1 done return 0 } Show_LST_Config() { $CMD_BOX --title "$FILE_LST_CONF" --text ":SHOW_LST_CONFIG_TEXT:" --browse $FILE_LST_CONF } Show_System_Config() { $CMD_BOX --title "$FILE_SYSTEM_CONF" --text ":SHOW_SYSTEM_CONFIG_TEXT:" --browse $FILE_SYSTEM_CONF } Show_Boot_Msg() { dmesg > $FILE_BOOT_MSG if [ -f $FILE_BOOT_MSG ]; then $CMD_BOX --title "$FILE_BOOT_MSG" --text ":SHOW_BOOT_MSG_TEXT:" --browse $FILE_BOOT_MSG else Error "$FILE_BOOT_MSG ; :ERR_FILE_NOT_FOUND:" fi } # libLSTdisk - disk handling library shared between several scripts # # Copyright (C) 1993-1997 Ralf Flaxa, LST Software GmbH, Erlangen, Germany # # List_PARTITION ( [TYPE] ) # # TYPE may be DOS, Linux, Swap, Swapfile, HPFS, Bootmanager, Src, Dest, # the name of a partition or omitted (all partitions) # outputs lines in raw format # List_PARTITION() { if [ $# -eq 0 ]; then sysinfo --box --partition else case $1 in DOS|Linux|Dest|Src|HPFS|Swap|Swapfile|Bootmanager) sysinfo --box -C $1 --partition ;; DestSorted) sysinfo --box -C Linux --partition sysinfo --box -C DOS --partition ;; *) sysinfo --box -P $1 --partition ;; esac fi } # Build_PARTITION ( [--exclude FILE] [TYPE] ) # # TYPE may be DOS, Linux, Swap, Swapfile, HPFS, Bootmanager, Src, Dest, # the name of a partition or omitted (all partitions) # outputs lines in menu-item format and adds extra input possibility # Build_PARTITION() { local exclude_file= if [ $# -gt 1 -a "$1" = '--exclude' ]; then exclude_file="$2" shift 2 fi Debug "Building partition-list with argument <$1>" if [ -n "$exclude_file" -a -s "$exclude_file" ]; then Debug "Respecting exclude file $exclude_file:" Debug -c cat $exclude_file sed 's/$/ /' $exclude_file > $exclude_file.tmp List_PARTITION $1 | fgrep -vf $exclude_file.tmp rm -f $exclude_file.tmp else Debug "No or empty exclude file specified" List_PARTITION $1 fi Is_Expert && echo "\"other\" \":DEVICE_DIRECT:\" \\" return 0 } Build_HARDDISK_DEV() { sysinfo --box --disk } Build_Fstab_Menu() { do_quote -f $FILE_ETC_FSTAB | sed 's/ / /g' >> $FILE_TMP_COMMAND echo "2> $FILE_TMP_ANSWER" >> $FILE_TMP_COMMAND chmod 755 $FILE_TMP_COMMAND } Menu_Config_Swap() { local swapdir=/swap local swapfile=swapfile local swapdev= local swaptype=swap local swapsize= local partid= local defval= defval="`get_val CONF_PARTITIONS_SWAP | cut -d' ' -f 1`" if [ -z "$defval" ]; then defval="`sysinfo --tag -C Swap --partition | sed -n '1p'`" fi while [ 1 ]; do # FIXME: enable swapfile-option Choose --none --menutitle ":CHOOSE_PARTITION_SWAP_MENUTITLE:" --build "Build_PARTITION Swap" SWAP $defval || return 1 swapdev="$ANSWER" if [ -z "$ANSWER" ]; then return 0 ; fi partid="`Get_Partition_Info --id $swapdev`" case $partid in 1|4|6|11|12|14) swaptype=umsdos ;; 130) swaptype=swap swapsize="`Get_Partition_Info --size $swapdev`" ;; 131) swaptype=ext2 ;; esac case $swaptype in swap) swapoff $swapdev > /dev/null 2>&1 Info ":INFO_SWAP_INITIALIZING:" mkswap -c $swapdev $swapsize | Debug -p || continue Info ":INFO_SWAP_ACTIVATING:" sync sync sync sync sleep 3 swapon $swapdev || continue if [ -d $DIR_TARGET/etc ]; then echo "$swapdev none swap defaults 0 0" >> $DIR_TARGET/$FILE_ETC_FSTAB else echo "$swapdev" > $FILE_SWAP_SEL fi return 0 ;; umsdos|ext2) mkdir -p $swapdir Do_Mount -t $swaptype $swapdev $swapdir || continue if [ "$swaptype" = "umsdos" ]; then mkdir -p $swapdir/linux swapfile=linux/swapfile fi if [ -f $swapdir/$swapfile ]; then swapsize="`filesize $swapdir/$swapfile`" swapsize="`do_calc $swapsize / 1024`" dummy=":PARTITION: $swapdev ; :FILE: $swapfile ; :SIZE: ${swapsize}kB ; " Ask_Bool --pretext "$dummy" SWAP_FILE j || continue if [ "$ANSWER" = "1" ]; then rm -f $swapdir/$swapfile fi fi if [ ! -f $swapdir/$swapfile ]; then swapsize="`df /swap | fgrep $swapdev | cut -c 37-45`" if [ $swapsize -gt 8192 ]; then swapsize=8192 elif [ $swapsize -gt 4096 ]; then swapsize=4096 else Msg ":WARN_NO_SPACE_FOR_SWAPFILE:" continue fi fi ;; esac Info ":INFO_SWAP_INITIALIZING:" if [ ! -f $swapdir/$swapfile ]; then dd if=/dev/zero of=$swapdir/$swapfile bs=1k count=$swapsize || continue sync fi mkswap $swapdir/$swapfile $swapsize || continue Info ":INFO_SWAP_ACTIVATING:" sync sync sync sync sleep 3 swapon $swapdir/$swapfile || continue if [ -d $DIR_TARGET/etc ]; then echo "$swapdir/$swapfile none swap defaults 0 0" >> $DIR_TARGET/$FILE_ETC_FSTAB fi # do we have less than 12 MB and no swap enabled? if [ `filesize /proc/kcore` -lt 12582912 -a \ "`sysinfo --swap --var 2>&1 >/dev/null | cut -d':' -f 2`" -eq 0 ]; then echo "NOT_ENOUGH_RAM" >> $FILE_TMP_ERR Error2 NOT_ENOUGH_RAM # do not let them proceed as it won't work anyway continue fi return 0 done } # test harddisk geometry # Check_Disk_Geometry() { local f_name=Check_Disk_Geometry local f_args=1 # (hardisk) -> local harddisk= local diskname= local geometry= local cylinders= local heads= local sectors= local warning= Check_Args $f_name $f_args $# "$@" || return 255 harddisk=$1 diskname="`echo $harddisk | sed 's/^\/dev\///'`" geometry="`Get_Val CONF_DISK_GEO_$diskname`" 2> /dev/null if [ -z "$geometry" ]; then geometry="`sysinfo --var --disk $harddisk 2>&1 >/dev/null | cut -d: -f 3,4,5 `" IFS=':' read cylinders heads sectors << EOF $geometry EOF else read cylinders heads sectors << EOF $geometry EOF fi # check for invalid number of cylinders and warn if > 1024 if [ -z "$cylinders" -o $cylinders -le 0 ]; then warning=INVALID_GEOMETRY else if [ $cylinders -gt 1024 ]; then warning=MANY_CYLINDERS fi fi # check for invalid number of heads if [ -z "$heads" -o $heads -gt 255 -o $heads -le 0 ]; then warning=INVALID_GEOMETRY fi # check for invalid number of sectors if [ -z "$sectors" -o $sectors -gt 63 -o $sectors -le 0 ]; then warning=INVALID_GEOMETRY fi if [ -n "$warning" ]; then Warn2 $warning return 1 fi return 0 } Check_Mount_Partition() { local f_name=Check_Mount_Partition local f_args=1 # (partition) -> ERROR, STATUS local busydir= Check_Args $f_name $f_args $# "$@" || return 255 Check_Partition_Valid $1 || return 1 mount | cut -d' ' -f 1 | fgrep -x "$1" > /dev/null 2>&1 if [ $? -ne 0 ]; then ERROR="$1 ; :ERR_PARTITION_NOT_MOUNTED:" return 1 else busydir="`mount | fgrep "$1 on" | cut -d' ' -f 3`" if [ -n "$busydir" ]; then busydir="(${busydir})" fi STATUS="$1 $busydir ; :ERR_PARTITION_ALREADY_MOUNTED:" return 0 fi } Check_Directory() { local f_name=Check_Directory local f_args=1 # (directory) -> ERROR Check_Args $f_name $f_args $# "$@" || return 255 if [ -d $1 ]; then return 0 else ERROR="$1 ; :ERR_DIRECTORY_INVALID:" return 1 fi } # checks if directory is mountable and if false sets STATUS to device # and ERROR to an error message # Check_Directory_Busy() { local f_name=Check_Directory_Busy local f_args=1 # (directory) -> STATUS, ERROR export STATUS= export ERROR= Check_Args $f_name $f_args $# "$@" || return 255 Check_Directory $1 || return 1 mount | cut -d' ' -f 3 | fgrep -x "$1" > /dev/null 2>&1 if [ $? -eq 0 ]; then STATUS="`mount | fgrep "on $1" | cut -d' ' -f 1`" Debug "directory $1 is busy because $STATUS is mounted" ERROR="$1 ; :ERR_DIRECTORY_BUSY:" return 0 fi Debug "directory $1 is not busy" return 1 } # checks if a device is already mounted and if true sets STATUS to directory # and ERROR to an error message # Check_Device_Mounted() { local f_name=Check_Device_Mounted local f_args=1 # (device) -> STATUS, ERROR export STATUS= export ERROR= Check_Args $f_name $f_args $# "$@" || return 255 # FIXME handle devices too (as NFS-Paths), not only partitions mount | cut -d' ' -f 1 | fgrep -x "$1" >/dev/null 2>&1 if [ $? -eq 0 ]; then STATUS="`mount | fgrep "$1 on" | cut -d' ' -f 3`" Debug "device $1 is already mounted on $STATUS" ERROR="$1 ; :ERR_PARTITION_ALREADY_MOUNTED:" return 0 fi Debug "device $1 is not mounted" return 1 } # checks if a partition is a primary partition and if false sets # ERROR to an error message # Check_Partiton_Primary() { local f_name=Check_Partition_Primary local f_args=1 # (partition) -> ERROR export ERROR= Check_Args $f_name $f_args $# "$@" || return 255 Check_Partition_Valid $1 || return 1 if [ `echo $1 | cut -c 9-` -lt 5 ]; then if [ `Get_Partition_Info --id $1` -ne 5 ]; then return 0 fi fi ERROR="$1 ; :ERR_NO_PRIMARY_PARTITION:" return 1 } # checks if a partition is valid and if false sets ERROR to an error message # Check_Partition_Valid() { local f_name=Check_Partition_Valid local f_args=1 # (partition) -> ERROR export ERROR= # Debug "Check_Partition_Valid: $@" Check_Args $f_name $f_args $# "$@" || return 255 if [ ! -b $1 ]; then ERROR="$1 ; :ERR_INVALID_BLOCK_DEVICE:" return 1 fi dummy="`sysinfo -P $1 --partition --var 2>&1 >/dev/null`" if [ -z "$dummy" ]; then ERROR="$1 ; :ERR_PARTITION_NOT_FOUND:" return 1 fi return 0 } # Smart mount frontend # # returns: # 0 ok # 1 was already mounted # 2 could not be mounted # 255 parameter error # Do_Mount() { local f_name=Do_Mount local f_args=2 # ([--verbose] [--types TYPES] [-t TYPE] [-o OPTIONS] # DEVICE DIRECTORY) -> ERROR local verbose_mode= local mounttype= local mountopt= local mountdev= local mountdir= local mountline= local partid= local dummy= local loop= local mounttypealt="ext2 umsdos msdos minix iso9660 hpfs" export ANSWER= # parse options while [ 1 ]; do if [ $# -gt 1 ]; then case $1 in --types) mounttypealt="$2" shift 2 continue;; -t) mounttype="$2" mounttypealt="" shift 2 continue;; -o) mountopt="$2" shift 2 continue;; esac fi if [ $# -gt 0 ]; then case $1 in --verbose) verbose_mode=true shift 1 continue;; esac fi Check_Args $f_name $f_args $# "$@" || return 255 mountdev=$1 mountdir=$2 shift 2 break done if [ -z "$mounttype" ]; then # try to determine mounttype # check for nfs mount if [ -n "`echo $mountdev | sed -n '/:/p'`" ]; then mounttype=nfs mounttypealt= # shift 1 # check for device mount elif [ -n "`echo $mountdev | sed -n '/^\/dev\//p'`" ]; then # check for iso9660 mount (dirty hack) if [ -n "`echo $mountdev | sed -n '/cd/p'`" ]; then mounttype=iso9660 mountopt="ro" # check for floppy mount (dirty hack) elif [ -n "`echo $mountdev | sed -n '/^\/dev\/fd/p'`" ]; then mounttype=msdos mounttypealt="minix umsdos" # check for partition mount (dirty hack) elif [ -n "`echo $mountdev | sed -n '/^\/dev\/[irshx]d/p'`" ]; then # Get partition id partid="`Get_Partition_Info --id $mountdev`" if [ -z "$partid" ]; then Error "partition-id of $mountdev could not be determined!" return 1 fi case $partid in 1|4|6|11|12|14) mounttype="msdos" mounttypealt="umsdos" ;; 7) mounttype="hpfs" mounttypealt="msdos umsdos" ;; 128|129) mounttype="minix" mounttypealt="ext2" ;; 130) mounttype="swap" ;; 131) mounttype="ext2" mounttypealt="minix ext xiafs" ;; *) Error "unknown partition-id $partid for $mountdev!" return 2 ;; esac fi # no partition fi # no device fi # mounttype="" # mount loop rm -f $FILE_TMP_ERR for loop in $mounttype $mounttypealt ; do Do_Load_Driver filesystem $mounttype || continue Check_Device_Mounted $mountdev if [ $? -eq 0 ]; then if [ "$STATUS" = "$mountdir" ]; then Debug "keep it mounted. Ok" mount | fgrep "$mountdev on" | cut -d' ' -f 5 > $FILE_TMP_VAL ANSWER="`cat $FILE_TMP_VAL`" return 0 else Debug "unmount it." Do_Umount $mountdev fi fi Check_Directory_Busy $mountdir if [ $? -eq 0 ]; then if [ "$STATUS" = "$mountdev" ]; then Debug "keep it mounted. Ok" mount | fgrep "$mountdev on" | cut -d' ' -f 5 > $FILE_TMP_VAL ANSWER="`cat $FILE_TMP_VAL`" return 0 else Debug "unmount it." Do_Umount $mountdir fi fi dummy= if [ -n "$mountopt" ]; then dummy="-o $mountopt" fi rm -f /etc/mtab~ if [ "$loop" = "nfs" ]; then Info ":INFO_TRYING_NFS_MOUNT:" fi Debug "Trying mount -t $loop $dummy $mountdev $mountdir" # Do_Clear_Screen # echo "trying: mount -t $loop $dummy $mountdev $mountdir" mount -t $loop $dummy $mountdev $mountdir > $FILE_TMP_ERR.tmp 2>&1 retval=$? if [ $retval -eq 0 ]; then # Success Debug "Success!" # if [ -n "$verbose_mode" ]; then # Info ":PARTITION: = $mountdev ; :DIRECTORY: = $mountdir ; :FILESYTEM_TYPE: = $mounttype ; :INFO_MOUNT_SUCCESS:" # sleep 1 # fi ANSWER="$loop" return 0 else # Failure Debug "Failed!" Debug -c cat $FILE_TMP_ERR.tmp cat $FILE_TMP_ERR.tmp >> $FILE_TMP_ERR fi done # if [ -n "$verbose_mode" ]; then Error2 MOUNT_FAILED # fi return 2 } Do_Umount() { local f_name=Do_Umount local f_args=1 # (device/nfs-path/directory) -> Check_Args $f_name $f_args $# "$@" || return 255 while [ 1 ]; do rm -f /etc/mtab~ Debug "unmounting $1 ..." umount $1 >$FILE_TMP_ERR 2>&1 if [ $? -ne 0 ]; then fgrep "not mounted" $FILE_TMP_ERR >/dev/null && return 0 fgrep "not found" $FILE_TMP_ERR >/dev/null && return 0 Error2 UMOUNT_FAILED || return 1 else return 0 fi done } Get_Filesystem_Usage() { local cut="1-10,18-28,37-45,47-53,56-" # CHECK-ray: 'used' right-aligns with number, not '%', thus # extending space between 'used' and 'mount' ... echo "Filesystem size(kB) free(kB) used mount point" if [ "$1" = "--install" ]; then shift if [ "$DIR_TARGET" != "/" ]; then # display ONLY target devices on their future mount points df | cut -c $cut | \ fgrep -v "Filesystem" | \ fgrep '/root' | \ sed 's: /root/linux: /:' | \ sed 's: /root: /:' | \ sed 's://:/:' else df -t ext2 | cut -c $cut | \ fgrep -v "Filesystem" fi elif [ -e "$1" ]; then df $1 | cut -c $cut | \ fgrep -v "Filesystem" else df | cut -c $cut | \ fgrep -v "Filesystem" fi } # Get_Partition_Info ( { --boot, --size, --id, --type} PARTITION ) # # return: # 0 ok # 1 no partition specified # 2 partition not found # 3 no value available # Get_Partition_Info() { FUNC_NAME=Get_Partition_Info local field= # Debug "Get_Partition_Info: $@" if [ $# -gt 0 ]; then if [ "$1" = '--boot' ]; then field=3 shift 1 elif [ "$1" = '--size' ]; then field=4 shift 1 elif [ "$1" = '--id' ]; then field=5 shift 1 elif [ "$1" = '--type' ]; then field=6 shift 1 else field= fi fi Check_Partition_Valid $1 || return 1 dummy="`sysinfo -P $1 --partition --var 2>&1 >/dev/null | cut -d':' -f $field`" if [ -z "$dummy" ]; then Error "no value available for field $field" return 3 fi # Debug "Get_Partition_Info: result = <$dummy>" echo "$dummy" return 0 } Build_FLOPPY() { local val1= local val2= val1=" (`Get_Val CONF_FLOPPY1_DEV`)" val2=" (`Get_Val CONF_FLOPPY2_DEV`)" if [ -n "$val1" ]; then echo "--default \"1\" \\" elif [ -n "$val2" ]; then echo "--default \"2\" \\" fi if [ "$val1" = " ()" ]; then val1= fi echo "\"1\" \":FLOPPY_DRIVE: A $val1\" \\" if [ "$val2" = " ()" ]; then val2= fi echo "\"2\" \":FLOPPY_DRIVE: B $val2\" \\" } Build_FLOPPY_DEV() { List box FLOPPY_DEV $1 cat << EOF "/dev/fd$1" ":TYPE_FLOPPY_AUTO:" \\ EOF } Menu_Config_Floppy() { local drive= local val= while [ 1 ]; do Choose --none --other --menu --build "Build_FLOPPY" FLOPPY 1 || return 1 drive=$ANSWER val="`do_calc $drive - 1`" Choose --none --other --build "Build_FLOPPY_DEV ${val}" FLOPPY_DEV CONF_FLOPPY${drive}_DEV || return 1 Do_Store CONF_FLOPPY${drive}_DEV "$ANSWER" done } Menu_Harddisk_Parameters() { local harddisk= local diskname= local cylinders= local heads= local sectors= local geometry= if [ $# -ne 1 ]; then Panic ":ERR_WRONG_NUM_OF_ARGS:" fi harddisk=$1 diskname="`echo $harddisk | sed 's/^\/dev\///'`" geometry="`Get_Val CONF_DISK_GEOMETRY_$diskname`" 2> /dev/null if [ -z "$geometry" ]; then geometry="`sysinfo --var --disk $harddisk 2>&1 >/dev/null | cut -d: -f 3,4,5 `" IFS=':' read cylinders heads sectors << EOF $geometry EOF else read cylinders heads sectors << EOF $geometry EOF fi while [ 1 ]; do # Ask_Bool --pretext ":HARDDISK: $harddisk ; CHS=$cylinders/$heads/$sectors ; " HARDDISK_PARAMETERS || return 1 Ask_Bool --text ":HARDDISK: $harddisk ; CHS=$cylinders/$heads/$sectors ; :ASK_HARDDISK_PARAMETERS_HELP:" HARDDISK_PARAMETERS || return 1 case $ANSWER in 0) break ;; 1) # Cylinders Ask_String CYLINDERS $cylinders || return 1 cylinders="$ANSWER" # Heads Ask_String HEADS $heads || return 1 heads="$ANSWER" # Sectors Ask_String SECTORS $sectors || return 1 sectors="$ANSWER" ;; esac done Do_Store CONF_DISK_GEOMETRY_$diskname "$heads $sectors $cylinders" } # returns 0 on mke2fs success # returns 1 on error or abort # returns 2 of mke2fs was skipped # Menu_Call_Mke2fs() { local badblocks_flag= local reserved_flag= local inodes_flag= local partid= # FIXME. Set Name in text # test for type Linux native partid="`Get_Partition_Info --id $1`" if [ -n "$partid" -a "$partid" != "131" ]; then Error "Partition $1 ; :ERR_NO_LINUX_PARTITION:" return 1 fi # test whether it's mounted mount | fgrep "$1 " >/dev/null 2>&1 if [ $? -eq 0 ]; then Error "Partition $1 ; :ERR_PARTITION_ALREADY_MOUNTED:" return 1 fi Ask_Bool --pretext "Partition $1 ; " CALL_MKE2FS || return 1 if [ "$ANSWER" = "1" ]; then return 2 ; fi Is_Expert if [ $? -eq 0 ]; then while [ 1 ]; do # Ask_String MKE2FS_INODES "4096" Ask_String --pretext "Partition $1 ; " MKE2FS_INODES "4096" || return 1 if [ -n "$ANSWER" ]; then if [ $ANSWER -gt 1023 ]; then break ; fi fi Error ":ERR_INVALID_ANSWER:" || return 1 done inodes_flag="-i $ANSWER" while [ 1 ]; do # Ask_String MKE2FS_RESERVED "5" Ask_String --pretext "Partition $1 ; " MKE2FS_RESERVED "5" || return 1 if [ -n "$ANSWER" ]; then if [ 0 -le $ANSWER -a $ANSWER -lt 100 ]; then break ; fi fi Error ":ERR_INVALID_ANSWER:" done reserved_flag="-m $ANSWER" fi badblocks_flag="-c" Ask_Bool --pretext "Partition $1 ; " MKE2FS_BADBLOCKS n || return 1 if [ "$ANSWER" = "1" ]; then badblocks_flag= fi Do_Clear_Screen prep_use PREPARE || return 1 $DO_SIMULATE mke2fs $badblocks_flag $reserved_flag $inodes_flag $1 2>&1 || return 1 return 0 } Menu_Call_Fdisk() { local diskname local mbrfile local crc1 local crc2 local fdisk_retval if [ $# -ne 1 ]; then Panic ":ERR_WRONG_NUM_OF_ARGS:" fi Check_Disk_Geometry $1 if [ $? -ne 0 ]; then Menu_Harddisk_Parameters $1 fi diskname="`echo $1 | sed 's/^\/dev\///'`" mbrfile=$DIR_LST_TMP/mbr${diskname} # safe boot sector before calling fdisk dd if=$1 of=$mbrfile bs=512 count=1 >/dev/null 2>&1 gzip -f $mbrfile $CMD_BOX --help ":MENU_CALL_FDISK_HELP:" \ --title ":MENU_CALL_FDISK_TITLE:" \ --bool ":MENU_CALL_FDISK_TEXT:" 2> $FILE_TMP_ANSWER || return 1 ANSWER="`cat $FILE_TMP_ANSWER`" if [ "$ANSWER" != "0" ]; then return 1 ; fi Do_Clear_Screen if [ -f /mnt/install/live/lisa/usr/doc/LST/use-fdisk.gz ]; then zcat /mnt/install/live/lisa/usr/doc/LST/use-fdisk.gz else if [ -f /usr/doc/LST/use-fdisk.gz ]; then zcat /usr/doc/LST/use-fdisk.gz fi fi fdisk "$1" fdisk_retval="$?" # safe boot sector after calling fdisk dd if=$1 of=$mbrfile.new bs=512 count=1 >/dev/null 2>&1 gzip -f $mbrfile.new # compare by gzip CRC (no space for cmp or diff on rootdisk) crc1="`gzip -vl $mbrfile.gz | fgrep mbr${diskname} | cut -c 7-14`" crc2="`gzip -vl $mbrfile.new.gz | fgrep mbr${diskname}.new | cut -c 7-14`" if [ "$crc1" != "$crc2" ]; then Warn ":WARN_PARTITION_TABLE_MODIFIED:" if [ $fdisk_retval != 0 ]; then export NEED_TO_REBOOT=true else export NEED_TO_REBOOT=possible fi fi rm -f $mbrfile.gz $mbrfile.new.gz return 0 } Menu_Config_Harddisk() { local command local harddisk local partition while [ 1 ]; do $CMD_BOX --help ":MENU_CONFIG_HARDDISK_HELP:" \ --title ":MENU_CONFIG_HARDDISK_TITLE:" \ --menu ":MENU_CONFIG_HARDDISK_TEXT:" \ "Menu_Harddisk_Parameters" ":MENU_HARDDISK_PARAMETERS:" \ "Menu_Call_Fdisk" ":MENU_CALL_FDISK:" \ "Menu_Call_Mke2fs" ":MENU_CALL_MKE2FS:" 2> $FILE_TMP_ANSWER || return 1 command="`cat $FILE_TMP_ANSWER`" case $command in Menu_Call_Mke2fs) Choose --menutitle ":CHOOSE_PARTITION_MENUTITLE:" --build "Build_PARTITION Linux" PARTITION || return 1 partition="$ANSWER" $command $partition ;; Menu_Call_Fdisk|Menu_Harddisk_Parameters) Choose --other HARDDISK_DEV || continue harddisk="$ANSWER" # FIXME: real GEOMETYRY $command $harddisk ;; esac done } Menu_Show_Mounted() { mount > $FILE_TMP_COMMAND $CMD_BOX --help ":MENU_SHOW_MOUNTED_HELP:" \ --title ":MENU_SHOW_MOUNTED_TITLE:" \ --text ":MENU_SHOW_MOUNTED_TEXT:" \ --browse $FILE_TMP_COMMAND 2> $FILE_TMP_ANSWER || return 1 return 0 } Menu_Show_Fstab() { $CMD_BOX --help ":MENU_SHOW_FSTAB_HELP:" \ --title ":MENU_SHOW_FSTAB_TITLE:" \ --text ":MENU_SHOW_FSTAB_TEXT:" \ --browse $FILE_ETC_FSTAB 2> $FILE_TMP_ANSWER || return 1 return 0 } Menu_Fstab_Entry_Add() { local dummy= local partition= local partid= local mounttype= local mountpoint= local mountopts= while [ 1 ]; do rm -f $FILE_ETC_FSTAB.tmp mounttype= while [ 1 ]; do $CMD_BOX --help ":MENU_FSTAB_ENTRY_ADD_HELP:" \ --title ":MENU_FSTAB_ENTRY_ADD_TITLE:" \ --string ":MENU_FSTAB_ENTRY_ADD_TEXT:" 2> $FILE_TMP_ANSWER || return 1 partition="`cat $FILE_TMP_ANSWER`" sed -n "\,^$partition[ ]*,p" $FILE_ETC_FSTAB > $FILE_TMP_VAL if [ -s $FILE_TMP_VAL ]; then Error --file $FILE_TMP_VAL ":ERR_FSTAB_ENTRY_EXISTS:" continue else rm -f $FILE_TMP_VAL break fi done # test for type NFS if [ -n "`echo $partition | sed -n '/:/p'`" ]; then Debug "NFS-entry: <$partition>" mounttype="nfs" else # test for other types Debug "Partition-entry: <$partition>" Debug "Calling Check_Partition_Valid $partition" Check_Partition_Valid $partition if [ $? -ne 0 ]; then Error "$partition is not a valid partition!" continue fi # Get partition id Debug "Calling Get_Partition_Info --id $partition" partid="`Get_Partition_Info --id $partition`" Debug "partid=<$partid>" if [ -z "$partid" ]; then Error "partition-id of $partition could not be determined!" continue fi case $partid in 1|4|6|11|12|14) mounttype="msdos" ;; 7) mounttype="hpfs" ;; 128|129) mounttype="minix" ;; 130) mounttype="swap" ;; 131) mounttype="ext2" ;; *) Error "unknown partition-id $partid!" continue ;; esac fi if [ "$mounttype" = "swap" ]; then echo "$partition none swap default 0 0" > $FILE_ETC_FSTAB.tmp else $CMD_BOX --help ":MENU_FSTAB_ENTRY_ADD_MOUNTPOINT_HELP:" \ --title ":MENU_FSTAB_ENTRY_ADD_MOUNTPOINT_TITLE:" \ --string ":MENU_FSTAB_ENTRY_ADD_MOUNTPOINT_TEXT:" 2> $FILE_TMP_ANSWER if [ $? -ne 0 ]; then continue; fi mountpoint="`cat $FILE_TMP_ANSWER`" if [ "$mounttype" = "hpfs" ]; then mountopts="ro"; else $CMD_BOX --help ":MENU_FSTAB_ENTRY_ADD_MOUNTOPTS_HELP:" \ --title ":MENU_FSTAB_ENTRY_ADD_MOUNTOPTS_TITLE:" \ --menu ":MENU_FSTAB_ENTRY_ADD_MOUNTOPTS_TEXT:" \ "rw" ":MOUNT_TYPE_READ_WRITE:" \ "ro" ":MOUNT_TYPE_READ_ONLY:" 2> $FILE_TMP_ANSWER if [ $? -ne 0 ]; then continue; fi mountopts="`cat $FILE_TMP_ANSWER`" fi if [ "$mounttype" = "nfs" ]; then echo "$partition $mountpoint $mounttype soft,bg,intr,nodev,nosuid,$mountopts 0 0" > $FILE_ETC_FSTAB.tmp else echo "$partition $mountpoint $mounttype $mountopts 0 2" > $FILE_ETC_FSTAB.tmp fi fi if [ ! -d $mountpoint ]; then mkdir -p $mountpoint fi cat $FILE_ETC_FSTAB.tmp >> $FILE_ETC_FSTAB Msg ":INFO_MOUNT_REBOOT:" return 0 done } Menu_Fstab_Entry_Del() { local del_entry= echo "$CMD_BOX --help \":MENU_FSTAB_ENTRY_DEL_HELP:\" --title \":MENU_FSTAB_ENTRY_DEL_TITLE:\" --one \":MENU_FSTAB_ENTRY_DEL_TEXT:\" \\" > $FILE_TMP_COMMAND Build_Fstab_Menu sh $FILE_TMP_COMMAND || return 1 del_entry="`cat $FILE_TMP_ANSWER`" $CMD_BOX --help ":MENU_FSTAB_ENTRY_DEL_ACK_HELP:" \ --title ":MENU_FSTAB_ENTRY_DEL_ACK_TITLE:" \ --bool "$del_entry ; :MENU_FSTAB_ENTRY_DEL_ACK_TEXT:" 2> $FILE_TMP_ANSWER || return 1 ANSWER="`cat $FILE_TMP_ANSWER`" case $ANSWER in 0) sed "\,^$del_entry,d" $FILE_ETC_FSTAB > $FILE_ETC_FSTAB.tmp mv $FILE_ETC_FSTAB.tmp $FILE_ETC_FSTAB return 0 ;; 1) return 1 ;; esac } Menu_Config_Mount() { while [ 1 ]; do $CMD_BOX --help ":MENU_CONFIG_MOUNT_HELP:" \ --title ":MENU_CONFIG_MOUNT_TITLE:" \ --menu ":MENU_CONFIG_MOUNT_TEXT:" \ "Menu_Show_Mounted" ":MENU_SHOW_MOUNTED:" \ "Menu_Show_Fstab" ":MENU_SHOW_FSTAB:" \ "Menu_Fstab_Entry_Add" ":MENU_FSTAB_ENTRY_ADD:" \ "Menu_Fstab_Entry_Del" ":MENU_FSTAB_ENTRY_DEL:" 2> $FILE_TMP_ANSWER COMMAND="`cat $FILE_TMP_ANSWER`" if [ -z "$COMMAND" ]; then break fi $COMMAND done rm -f $FILE_ETC_FSTAB.tmp return 0 } Show_Filesystem_Usage() { Get_Filesystem_Usage $1 > $FILE_TMP_VAL Browse2 $FILE_TMP_VAL FILESYSTEM_USAGE } # libLSTfirst - first install library shared between several scripts # # Copyright (C) 1993-1997 Ralf Flaxa, LST Software GmbH, Erlangen, Germany # Recover_COL11_Strings() { local my_lang="`Get_Val CONF_LST_LANG`" case $my_lang in de|us) ;; *) my_lang=us set_val CONF_LST_LANG us ;; esac Debug "trying to recover libLSTtext ($my_lang) from COL 1.1 CD" zcat /mnt/col/launch/dos/initrd.gz > /dev/ram2 mkdir -p /ram2 mount -t ext2 /dev/ram2 /ram2 # filter out my_lang zcat /ram2/usr/lib/LST/libLSTtext.gz | sed "{ s/^${my_lang}-x> // s/^x-x> // /^..-x> /d }" > /ram2/usr/lib/LST/libLSTtext Debug "merging with source file /ram2/usr/lib/LST/libLSTtext" Do_Merge_libLSTtext /usr/lib/LST/libLSTtext /ram2/usr/lib/LST/libLSTtext Debug "merging done" if [ -f /bin/freeramdisk.gz ]; then gunzip /bin/freeramdisk fi if [ -f /bin/freeramdisk ]; then freeramdisk /dev/ram2 fi umount /ram2 rm -fr /ram2 } Do_Read_Source() { local my_lang="`Get_Val CONF_LST_LANG`" Debug "CONF_LST_LANG=$my_lang" Info ":INFO_WAIT:" # check if we have pkg infos in the install tree for i in meta.db pkgs.all pkgs.db pkgs.idx pkgs.min pkgs.rec ; do if [ -f $DIR_DATA/$i ]; then Debug "using source file $DIR_DATA/$i" cp -a $DIR_DATA/$i /usr/lib/LST/$i fi done if [ -f $DIR_DATA/$my_lang/pkgs.idx ]; then Debug "using source file $DIR_DATA/$my_lang/pkgs.idx" cp -a $DIR_DATA/$my_lang/pkgs.idx /usr/lib/LST/pkgs.idx elif [ -f $DIR_DATA/us/pkgs.idx ]; then # if language specific not available use english Debug "using source file $DIR_DATA/us/pkgs.idx" cp -a $DIR_DATA/us/pkgs.idx /usr/lib/LST/pkgs.idx fi if [ "$INSTALL_MODE" = "OpenLinux" ]; then if [ -f $DIR_DATA/$my_lang/libLSTtext ]; then Debug "merging with source file $DIR_DATA/$my_lang/libLSTtext" Do_Merge_libLSTtext /usr/lib/LST/libLSTtext $DIR_DATA/$my_lang/libLSTtext Debug "merging done" elif [ -f $DIR_DATA/us/libLSTtext ]; then # if language specific not available use english Debug "merging with source file $DIR_DATA/us/libLSTtext" Do_Merge_libLSTtext /usr/lib/LST/libLSTtext $DIR_DATA/us/libLSTtext Debug "merging done" # NT does not properly handle TRANS.TBL files elif [ -f $DIR_DATA/$my_lang/liblstte ]; then Debug "merging with source file $DIR_DATA/$my_lang/liblstte" Do_Merge_libLSTtext /usr/lib/LST/libLSTtext $DIR_DATA/$my_lang/liblstte Debug "merging done" # NT does not properly handle TRANS.TBL files elif [ -f $DIR_DATA/us/liblstte ]; then Debug "merging with source file $DIR_DATA/us/liblstte" Do_Merge_libLSTtext /usr/lib/LST/libLSTtext $DIR_DATA/us/liblstte Debug "merging done" fi fi # this is to still support COL 1.1 installs as good as possible if [ -f /mnt/col/install/RPMS/lisa-2.3-7.i386.rpm ]; then Recover_COL11_Strings fi # check if we have private pkg infos in the install tree for i in meta.db pkgs.db pkgs.idx pkgs.sel ; do if [ -f $DIR_DATA/private/$i ]; then Debug "using source file $DIR_DATA/private/$i" cp -a $DIR_DATA/private/$i /usr/lib/LST/$i fi done # this is to check whether we have execute permissions for i in cpio rpm rpmextr ; do if [ ! -x /bin/$i ]; then chmod +x /bin/$i > /dev/null 2>&1 fi if [ ! -x /bin/$i ]; then Msg "/bin/$i ; :ERR_MISSING_EXEC_PERMISSIONS:" fi done prep_use SELECT } # converts decimal number to it's hexadecimal representation # on failure sets ERROR to an error message # Dec2Hex() { # printf "%02x\n" $1 # this would be too easy (and costs approx. 6k on floppy)... # so let's do it the HARD WAY(TM) !-) local n1=`do_calc $1 / 16` local t1=`do_calc $n1 \* 16` local n2=`do_calc $1 - $t1` local i= local r="" export ERROR= if [ "$1" -gt 255 ]; then ERROR="Dec2Hex: number too big ($1 > 255)" return 1 fi if [ $n1 -eq 0 ]; then n1=0 fi for i in $n1 $n2; do if [ $i -lt 10 ]; then r="${r}$i" else case "$i" in 10) r="${r}a" ;; 11) r="${r}b" ;; 12) r="${r}c" ;; 13) r="${r}d" ;; 14) r="${r}e" ;; 15) r="${r}f" ;; *) ERROR="Dec2Hex: illegal condition: remainder < 15"; return 1;; esac fi done echo "$r" return 0 } Set_Real_Root() { local root_dev= local driver= local disk= local base= local partition= local major= local minor= local high= local low= local bios_id= root_dev="`echo $1 | sed 's/^\/dev\///'`" driver="`echo $root_dev | cut -c 1-2`" if [ "$driver" = "rd" ]; then driver="`echo $root_dev | cut -c 1-5`" disk="`echo $root_dev | cut -c 7-7`" partition="`echo $root_dev | cut -c 9-`" base=8 elif [ "$driver" = "id" ]; then driver="`echo $root_dev | cut -c 1-6`" disk="`echo $root_dev | cut -c 8-8`" partition="`echo $root_dev | cut -c 10-`" base=8 else disk="`echo $root_dev | cut -c 3-3`" partition="`echo $root_dev | cut -c 4-`" base=64 fi case $driver in hd) if [ "$disk" = "a" -o "$disk" = "b" ]; then major=3 else major=22 fi ;; ida/c0) major=72 ;; rd/c0) major=48 ;; sd) base=16 major=8 ;; xd) major=13 ;; esac high="`Dec2Hex $major`" case $disk in a|0) minor=0 ;; b|1) minor=1 ;; c|2) if [ "$driver" = "hd" ]; then minor=0 else minor=2 fi ;; d|3) if [ "$driver" = "hd" ]; then minor=1 else minor=3 fi ;; e|4) minor=4 ;; f|5) minor=5 ;; g|6) minor=6 ;; h|7) minor=7 ;; esac low="`do_calc $minor \* $base`" low="`do_calc $low \+ $partition`" low="`Dec2Hex $low`" bios_id="0x${high}${low}" Is_Expert if [ $? -eq 0 ]; then Ask_String ROOT_ID "$bios_id" || return 1 bios_id="$ANSWER" fi if [ -n "$bios_id" ]; then echo "$bios_id" > /etc/rootdev echo "$bios_id" > /proc/sys/kernel/real-root-dev fi } Do_Reboot() { Info ":INFO_REBOOTING:" sleep 3 Do_Clear_Screen reboot } Menu_Config_Partitioning() { local defval local trouble while [ 1 ]; do defval=n trouble= # do we have any target partition at all? if [ -z "`sysinfo -C Dest --notitle --noheader --partition`" ]; then trouble=NO_TARGET_AVAILABLE defval=y fi # do we have less than 12 MB but no swap partition? if [ `filesize /proc/kcore` -lt 12582912 -a \ -z "`sysinfo -C Swap --notitle --noheader --partition`" ]; then trouble=NOT_ENOUGH_RAM defval=y fi Ask_Bool CALL_FDISK $defval || return 1 if [ "$ANSWER" = "1" ]; then if [ -n "$trouble" ]; then echo "$trouble" >> $FILE_TMP_ERR Error2 $trouble continue fi return 0 fi Do_Modify_Partitioning || continue break done return 0 } Do_Modify_Partitioning() { local retval=1 while [ 1 ]; do while [ 1 ]; do # ask for hard disk Choose --none --other --build Build_HARDDISK_DEV HARDDISK_DEV || break if [ -z "$ANSWER" ]; then retval=0 break fi Menu_Call_Fdisk "$ANSWER" || continue done if [ -n "$NEED_TO_REBOOT" ]; then Ask_Bool NEED_TO_REBOOT || continue if [ "$ANSWER" = "0" ]; then Do_Reboot ; fi fi break done return $retval } Fix_uucp() { local i for i in /var/spool/uucp /var/spool/uucppublic ; do mkdir -p $DIR_TARGET${i} chown uucp.uucp $DIR_TARGET${i} chmod 1777 $DIR_TARGET${i} done i=/var/log/uucp touch $DIR_TARGET${i} chown uucp.uucp $DIR_TARGET${i} if [ -d $DIR_TARGET${i} ]; then chmod 775 $DIR_TARGET${i} else chmod 664 $DIR_TARGET${i} fi } Fix_sendmail_start() { set_val -f /root/etc/sysconfig/daemons/sendmail ONBOOT yes } Fix_httpd_start() { # this fix is for apache-1.1.1-10 if [ -d /root/usr/doc/apache-httpd-1.1.1-10 -a \ ! -f /root/etc/sysconfig/daemons/httpd ]; then cat << EOD > /root/etc/sysconfig/daemons/httpd IDENT=WWW DESCRIPTIVE="WEB server" ONBOOT=no VARIANT=apache EOD fi set_val -f /root/etc/sysconfig/daemons/httpd ONBOOT yes } Fix_passwd() { local nis_magic # grep out root account (with password) and adjust HOME sed -n '/^root:/p' /etc/passwd | sed 's/:\/:/:\/root:/' > /etc/passwd.tmp # append normal passwd (without root account) sed '/^root:/d' $DIR_TARGET/etc/passwd >> /etc/passwd.tmp nis_magic="`sed -n '/^+/p' /etc/passwd.tmp`" if [ -n "$nis_magic" ]; then sed '/^+/d' /etc/passwd.tmp > /etc/passwd.nismagic mv -f /etc/passwd.nismagic /etc/passwd.tmp fi # grep out normal account (with password) if [ -n "$LAST_USER" ]; then sed -n "/^$LAST_USER:/p" /etc/passwd >> /etc/passwd.tmp fi if [ -n "$nis_magic" ]; then echo "$nis_magic" >> /etc/passwd.tmp fi # on COL 2.2 setup does not provide a passwd, so we have to fix ours sed '{ /^install/d /^expert/d /^setup/d /^hilfe/d /^help/d s/Nobody:\/:/Nobody:\/:\/bin\/false/ }' /etc/passwd.tmp > /etc/passwd.tmp2 mv /etc/passwd.tmp2 /etc/passwd.tmp chown root.root /etc/passwd.tmp chmod 644 /etc/passwd.tmp mv /etc/passwd.tmp $DIR_TARGET/etc/passwd # if we are on a COL 1.2 install then switch to shadow passwords if [ "$INSTALL_MODE" = "OpenLinux" -a -x $DIR_TARGET/usr/sbin/pwconv ]; then Debug "calling pwconv to switch to shadow passwords" History_Install "calling pwconv to switch to shadow passwords" ( cd $DIR_TARGET; chroot $DIR_TARGET usr/sbin/pwconv ) > $DIR_TARGET/install/pwconv.error 2>&1 # remove empty error logs if [ ! -s $DIR_TARGET/install/pwconv.error ]; then rm -f $DIR_TARGET/install/pwconv.error fi fi return 0 } Menu_First_Install() { export INSTALL_STATE=3 local disk= local partition= local orig_source= local orig_dev= local orig_mode= local max_state_seen=-1 local instpkg="$DIR_LIVE/lizard/share/apps/lizard/extrabin/instpkg.sh" History "`date` $LOGNAME: LISA: first time install (${MODE_USER}-mode)" # FIXME: late fix for Caldera scd mv $FILE_SYSTEM_CONF $FILE_SYSTEM_CONF.tmp sed -e 's:/dev/sr:/dev/scd:g' < $FILE_SYSTEM_CONF.tmp > $FILE_SYSTEM_CONF rm -f $FILE_SYSTEM_CONF.tmp if [ -f /var/run/cardmgr.pid ]; then rm -f /sbin/cardmgr rm -fr /etc/pcmcia kill -9 `cat /var/run/cardmgr.pid` fi while [ 1 ]; do INSTALL_STATE="`do_calc $INSTALL_STATE - 1`" Debug "entering install stage $INSTALL_STATE ..." if [ $INSTALL_STATE -gt $max_state_seen ]; then max_state_seen=$INSTALL_STATE fi case $INSTALL_STATE in 0) # quit LISA end_use INSTALL end_use CALDERA_INSTALL end_use RPM_INSTALL end_use /usr/lib/LST/libLSTall return 1 ;; 1) # quit LISA Debug "User wanted to exit LISA. Not allowed in First_Install" return 1 ;; 2) # initial module management InitSubsystems || continue # exit now if we used "boot root=/dev/sdXX" at LILO prompt if [ -f /etc/install.skip ]; then sync Do_Clear_Screen exit 0 fi ;; 3) # allow repartitioning as soon as possible Debug "Before Menu_Config_Partitioning" Menu_Config_Partitioning || continue Debug "After Menu_Config_Partitioning" ;; 4) # enable swapspace as soon as possible # FIXME: omit this question if swapspace was already set up Menu_Config_Swap || continue # FIXME: check if we have less than 12 MB but no swap enabled? ;; 5) # choose install source (floppy, hard disk, CDROM, network, ...) Choose_Install_Source || continue # do read files from source Do_Read_Source ;; 6) # select target partition(s) prep_use PREPARE Choose_Install_Target || continue end_use PREPARE # do init target partition(s) Do_Init_Target ;; 7) # choose packages prep_use SELECT Menu_Pkg_Select || continue ;; 8) if [ -x $instpkg ]; then # install packages using instpkg.sh Info ":INFO_WAIT:" Do_PHI_Complete_Pkgs Do_Sort_Pkgs Msg2 PKG_INSTALL || continue # We have the target mounted under /root in # LISA mode so we have to modify instpkg.sh) umount $DIR_TARGET/proc > /dev/null 2>&1 sed '{ /^Target=\/mnt\/root/s/^Target=\/mnt\/root/Target=\/root/ }' $instpkg > /tmp/instpkg.sh chmod 755 /tmp/instpkg.sh Do_Clear_Screen echo "Calling package install tool ..." ( cd $DIR_TARGET ; /tmp/instpkg.sh $FILE_PKGS_SEL ) else # install packages the old way prep_use INSTALL Do_Pkg_Install || continue end_use SELECT end_use INSTALL Do_Fixes_After_Pkg_Install Do_Save_Package_Selection fi INSTALL_STATE="`do_calc $INSTALL_STATE + 1`" ;; 9) # FIXME: issue a warning that backsptep means reinstall or reboot Error ":ERR_BACKSTEP_NOT_POSSIBLE:" Ask_Bool ABORT_INSTALL y if [ "$ANSWER" = "0" ]; then Do_Reboot fi ;; 10) # initial system configuration (to be replaced by COAS) Menu_First_Config || continue Do_Fixes_After_First_Config # umount the second mount of /proc umount /root/proc ;; 11) History "`date` $LOGNAME: primary installation completed" History "===============================================================" # this file is used as a marker to show that the install is complete touch /etc/install.done umount /mnt >/dev/null 2>&1 rmmod smbfs >/dev/null 2>&1 if [ "`get_val -f /etc/lst.cnf CONF_COL_EDITION`" != "SBA" ]; then Msg2 GRATULATIONS || continue fi # FIXME: need better method to find initrd if [ "`uname -r`" != "1.2.13" ]; then sync Do_Clear_Screen exit 0 else Do_Reboot_System fi ;; esac INSTALL_STATE="`do_calc $INSTALL_STATE + 2`" done } Do_Set_Password() { local username=$1 prep_use /bin/passwd reset 2>&1 Do_Clear_Screen # small passwd wrapper while [ 1 ]; do touch /tmp/.passwd echo "Setting password for $username:" if [ "$MODE_QUERY" = "auto" ]; then sleep 1 # sleep a second to make sure file is older sed "s/^$username:[^:]*:/$username:*notset*:/" /etc/passwd > /etc/passwd.tmp chown root.root /etc/passwd.tmp chmod 644 /etc/passwd.tmp mv /etc/passwd.tmp /etc/passwd else passwd $username 2>&1 fi if [ /etc/passwd -nt /tmp/.passwd ]; then break fi done return 0 } Do_Set_Root_Password() { Msg2 SET_ROOT_PASSWD || return 1 Do_Set_Password root return 0 } Do_Create_First_User() { Msg2 CREATE_FIRST_USER || return 1 Menu_User_Add --first } Menu_Config_Network() { local s=2 while [ 1 ]; do s="`do_calc $s - 1`" Debug "entering net config stage $s ..." case $s in 0) return 1 ;; 1) Menu_Config_FQ_Name || continue Do_Ifcfg lo up ;; 2) Menu_Config_Ether || continue if [ "`Get_Val CONF_eth0_STAT`" != "up" -a \ "`Get_Val CONF_tr0_STAT`" != "up" ]; then # disable router, DNS and NIS # (this is dumb but prevents from trouble) # jump over the next steps CONF_ROUTER1_IP="" CONF_DNS_DOMAIN="" CONF_DNS_SEARCH="" CONF_DNS_SERVER1_IP="" CONF_DNS_SERVER2_IP="" CONF_DNS_SERVER3_IP="" CONF_NIS_DOMAIN="" CONF_NIS_SERVER1_IP="" CONF_NIS_SERVER2_IP="" CONF_NIS_SERVER3_IP="" s=99 fi ;; 3) Menu_Config_Router first || continue ;; 4) Menu_Config_DNS || continue ;; 5) if [ -x $DIR_TARGET/usr/sbin/ypbind ]; then Menu_Config_NIS || continue fi ;; *) return 0 ;; esac s="`do_calc $s + 2`" done } Build_Daemons() { local i local daemon local ghostdaemon local variant local descriptive local onboot local ident local desc local preset local have_mta=false for i in $DIR_TARGET/etc/sysconfig/daemons/* ; do if [ ! -f $i ]; then continue ; fi daemon="`basename $i`" if [ "$daemon" = "mta" ]; then have_mta=true fi # filter out wrong (old) sendmail/smail files if mta exists if [ "$daemon" = "sendmail" -a "$have_mta" = "true" ]; then continue fi if [ "$daemon" = "smail" -a "$have_mta" = "true" ]; then continue fi # filter out .rpmsave and .rpmorig files ghostdaemon="`basename $i .rpmsave`" if [ "$daemon" != "$ghostdaemon" ]; then continue ; fi ghostdaemon="`basename $i .rpmorig`" if [ "$daemon" != "$ghostdaemon" ]; then continue ; fi # filter out .*~ files if [ "`echo "$daemon" | sed 's/^.*\(.\)$/\1/'`" = '~' ]; then continue fi hack="$daemon" onboot="`get_val -f $i ONBOOT`" ident="`get_val -f $i IDENT`" case $ident in DOSEmu) hack="DOS Emulation" ;; lpd) hack="Print Server" ;; news-system) hack="News Server" ;; nis-server) hack="NIS Server" ;; MTA) hack="Mail Server" ;; NFS) hack="NFS Server" ;; SAMBA) hack="SMB Server" ;; WWW) hack="WEB server" ;; esac descriptive="`get_val -f $i DESCRIPTIVE`" if [ -n "$descriptive" ]; then hack="$descriptive" fi variant="`get_val -f $i VARIANT`" desc= if [ -n "$variant" ]; then desc="$variant" fi if [ -n "$desc" ]; then desc=" (${desc})" fi preset=S case $onboot in no|NO|No) preset=U ;; esac # FIXME12: syslog does not respect the syntax. # set_val can not handle it. if [ "$daemon" = "syslog" ]; then preset=F fi echo "\"$daemon\" \"${hack}${desc}\" \"$preset\" \\" done } # Do_Setup_Daemon DAEMON {yes,no} # Do_Setup_Daemon() { local dir_daemons=$DIR_TARGET/etc/sysconfig/daemons # FIXME12: syslog does not respect syntax. set_val can not handle it. if [ "$1" = "syslog" ]; then return 0 fi if [ -f ${dir_daemons}/$1 ]; then set_val -f ${dir_daemons}/$1 ONBOOT $2 else echo "ONBOOT=$2" > ${dir_daemons}/$1 fi } Do_Setup_Daemons() { local i local daemon local daemon_list="$1" # Do the necessary enable/disable modifications for i in $DIR_TARGET/etc/sysconfig/daemons/* ; do if [ ! -f $i ]; then continue ; fi daemon="`basename $i`" if [ -n "`echo "$daemon_list" | fgrep ":${daemon}:"`" ]; then Do_Setup_Daemon $daemon yes else Do_Setup_Daemon $daemon no fi done # Save ':'-separated list of daemons to be autostarted Do_Store CONF_DAEMON_SERVICES "$daemon_list" } Menu_Config_Daemons() { local daemon local daemon_list Choose --multi --build Build_Daemons CONFIG_DAEMONS || return 1 # The list of selected daemons for autostart is now in $FILE_TMP_ANSWER # and we store it as a ':'-separated list in the CONF_DAEMON_SERVICES # variable in /etc/system.cnf for daemon in `cat $FILE_TMP_ANSWER` ; do daemon_list="${daemon_list}:${daemon}" done if [ -n "$daemon_list" ]; then daemon_list="${daemon_list}:" fi Do_Setup_Daemons "$daemon_list" return 0 } Get_MBR_dev() { sysinfo --tag -C MBR --disk } Replace_MBR() { local src=/boot/virgin.mbr local tgt=$1 if [ ! -f $src ]; then Debug "could not find $src to replace $tgt" return 1 fi dd if=$src of=$tgt bs=446 count=1 && { dd if=$src skip=510 bs=1 count=2 of=$tgt seek=510 && { Debug "sucessfully replaced $tgt with $src" return 0 } } Debug "problems replacing $tgt" return 1 } Do_Fix_MBR() { local boot_sig_crc="b016f118" local real_sig_crc= local mbr_dev= mbr_dev="`Get_MBR_dev`" if [ -z "$mbr_dev" ]; then Debug "Get_MBR_dev returned nothing" return 1 fi dd if=$mbr_dev bs=1 skip=510 count=2 of=/tmp/sig.mbr gzip -9 /tmp/sig.mbr real_sig_crc="`gzip -lv /tmp/sig.mbr.gz | fgrep -v method | cut -d' ' -f 2`" Debug "real_sig_crc was <$real_sig_crc>" if [ -z "$real_sig_crc" ]; then Debug "real_sig_crc was empty" return 1 fi if [ "$real_sig_crc" = "$boot_sig_crc" ]; then # for now be happy with that (simplified approach) return 0 fi Debug "real_sig_crc != boot_sig_crc ==> replacing MBR" Replace_MBR $mbr_dev || return 1 return 0 } Menu_First_Config() { local s if [ "`get_val -f /etc/lst.cnf CONF_COL_EDITION`" = "SBA" ]; then s=102 else s=2 fi Start_unconfigured_sh while [ 1 ]; do s="`do_calc $s - 1`" Debug "entering config stage $s ..." case $s in 0|100) return 1 ;; 1) Menu_Config_Network || continue ;; 101) Do_Setup_FQ_Name Do_Ifcfg lo up Do_Setup_Hosts if [ -z "`fgrep eth0 /proc/net/dev`" ]; then Error "$dev ; :ERR_NO_DEVICE_AND_NO_MODULE:" Do_Store CONF_eth0_STAT down else Do_Store CONF_eth0_STAT up Do_Store CONF_eth0_DEV "eth0" Do_Store CONF_eth0_NAME "sba.local" Do_Store CONF_eth0_IP "192.168.1.1" Do_Store CONF_eth0_MASK "255.255.255.0" Do_Store CONF_eth0_NET "192.168.1.0" Do_Store CONF_eth0_BCAST "192.168.1.255" Do_Store CONF_ROUTER1_IP "192.168.1.1" Do_Setup_Hosts Set_network Set_ifcfg eth0 Do_Ifcfg eth0 up > $FILE_TMP_ERR 2>&1 Do_Ifcfg default up fi Do_Store CONF_DNS_SERVER1_IP "192.168.1.1" Do_Setup_DNS ;; 2|102) Menu_Config_Timezone || continue ;; 3) Menu_Config_Mouse || continue ;; 4|103) Menu_Config_Printer || continue ;; 5|104) Do_Set_Root_Password || continue ;; 6|105) Do_Create_First_User || continue Fix_passwd ;; 7) # omit this question if install source was CD if [ "`Get_Val CONF_INSTALL_MEDIUM`" != "cdrom" ]; then Menu_Config_CD || continue fi ;; 8|106) prep_use LILO while [ 1 ]; do Menu_Config_LILO_HD && break Msg ":ERR_BACKSTEP_NOT_POSSIBLE:" done Do_Fix_MBR ;; 9) # configure daemons during first install Menu_Config_Daemons || continue ;; 10) # configure X during first install if [ -f $DIR_TARGET/usr/X11R6/bin/startx ]; then while [ 1 ]; do Menu_Config_X_Server && break Msg ":ERR_BACKSTEP_NOT_POSSIBLE:" done fi ;; 11) # store LISA configuration on floppy while [ 1 ]; do Menu_Store_LISA_Config && break Msg ":ERR_BACKSTEP_NOT_POSSIBLE:" done ;; 12|107) # first configuration finished return 0 ;; *) Panic "Menu_First_Config: should never get here." return 1 ;; esac s="`do_calc $s + 2`" done } Do_Save_Package_Selection() { if [ -f $FILE_PKGS_SEL ]; then cp -a $FILE_PKGS_SEL $DIR_TARGET/usr/lib/LST/pkgs.sel fi } Do_Store_LISA_Config() { local was_mounted= local happy local i while [ 1 ]; do happy=true mount | fgrep 'on /floppy' > /dev/null && was_mounted=true umount /floppy >/dev/null 2>&1 if [ $? -ne 0 ]; then echo "could not unmount" >> /dev/tty8 fi Msg ":DO_INSERT_DOS_FLOPPY:" || return 1 mount -t msdos /dev/fd0H1440 /floppy if [ $? -ne 0 ]; then Msg ":ERR_MOUNT_FLOPPY_FAILED:" return 1 else touch /floppy/writable if [ $? -ne 0 ]; then # floppy write protected # FIXME # Msg ":ERR_MOUNT_FLOPPY_FAILED:" Msg "Write failed. The floppy is write protected." continue else rm -f /floppy/writable fi fi Info ":INFO_WAIT:" mkdir -p /floppy/etc mkdir -p /floppy/usr/lib/LST for i in /etc/lst.cnf /etc/system.cnf /usr/lib/LST/pkgs.sel ; do if [ -f $i ]; then cp -a $i /floppy/$i if [ $? -ne 0 ]; then Debug "problems while copying $i" happy=false fi else Debug "$i can not be copied: file not found" happy=false fi done sync sync umount /floppy >/dev/null 2>&1 if [ "$happy" = "true" ]; then # FIXME # Msg ":INFO_WRITE_SUCCEEDED:" || continue Msg "The configuration has been saved successfully." || continue return 0 fi Msg ":ERR_WRITE_FAILED:" || return 1 done return 0 } Menu_Store_LISA_Config() { local defval if [ "$MODE_QUERY" = "auto" ]; then defval=n else defval=y fi while [ 1 ]; do Ask_Bool WRITE_CURRENT_CONFIG $defval || return 1 case $ANSWER in 0) Do_Store_LISA_Config || continue ;; esac return 0 done } Set_LISA_CONF() { mkdir -p $DIR_TARGET/etc # save lst setup cp -a /etc/lst.cnf $DIR_TARGET/etc # save system setup cp -a /etc/system.cnf $DIR_TARGET/etc # reset target and auto mode set_val -f $DIR_TARGET/etc/system.cnf DIR_TARGET "/" set_val -f $DIR_TARGET/etc/system.cnf MODE_QUERY "prompt" } Transfer_dev_symlinks() { local i # save mouse/modem/cdrom symlinks for i in mouse modem cdrom ; do if [ -L /dev/$i ]; then rm -f $DIR_TARGET/dev/$i cp -a /dev/$i $DIR_TARGET/dev fi done } Set_message() { conf_file=/boot/message # copy boot message if [ ! -f $DIR_TARGET$conf_file ]; then cp -a $conf_file $DIR_TARGET$conf_file fi } # FIXME: we have to rely that the linux symlink is there, otherwise # we are running into a chicken and egg problem to determine # the future value of 'uname -r' and 'uname -v'. Now use # the value of the running kernel as fallback Get_uname_r() { local uname_r if [ -f $DIR_TARGET/usr/src/linux/include/linux/version.h ]; then fgrep UTS_RELEASE $DIR_TARGET/usr/src/linux/include/linux/version.h | cut -d'"' -f 2 > $FILE_TMP_VAL uname_r="`cat $FILE_TMP_VAL`" else uname_r="`uname -r`" fi Debug "Get_uname_r returns $uname_r" echo "$uname_r" } Get_uname_v() { local uname_v if [ -f $DIR_TARGET/usr/src/linux/include/linux/compile.h ]; then fgrep UTS_VERSION $DIR_TARGET/usr/src/linux/include/linux/compile.h | cut -d'"' -f 2 > $FILE_TMP_VAL uname_v="`cat $FILE_TMP_VAL`" else uname_v="`uname -v`" fi Debug "Get_uname_v returns $uname_v" echo "$uname_v" } # # prepare a valid initrd (all relative to PWD) # Prepare_Initrd() { # FIXME12uname: because of the rebuild uname -v causes problems local uname_r="`Get_uname_r`" local uname_v="`Get_uname_v`" local mod_file="/etc/modules/${uname_r}/${uname_v}.rootfs" local driver local moddir local module local ans # create minimal directories mkdir -p bin dev etc/rc.d etc/modules/${uname_r} etc/modules/options lib/modules/${uname_r} sbin # create minimal devices mknod -m 644 dev/tty0 c 4 0 mknod -m 644 dev/tty1 c 4 1 ln -s tty0 dev/console # copy minimal libraries cp -a /lib/libc* lib cp -a /lib/ld.so* lib cp -a /etc/ld.so.conf etc # copy minimal binaries cp -a /bin/sh bin cp -a /sbin/insmod sbin cp -a /bin/uname bin cp -a /bin/cat bin for moddir in block cdrom fs ipv4 misc net pcmcia scsi sound ; do mkdir -p ./lib/modules/${uname_r}/$moddir done # copy rootfs module list and corresponding modules and params files if [ -f "$DIR_TARGET/$mod_file" ]; then cp -a "$DIR_TARGET/$mod_file" ./"$mod_file" cp -a "$DIR_TARGET/$mod_file" ./etc/modules/${uname_r}/rootfs # copy necessary modules for driver in `cat "$DIR_TARGET/$mod_file"` ; do for moddir in block cdrom fs ipv4 misc net pcmcia scsi sound ; do module=/lib/modules/${uname_r}/$moddir/${driver}.o # we use the modules from the target system if [ -f $DIR_TARGET/$module ]; then mkdir -p /lib/modules/${uname_r}/$moddir cp -a $DIR_TARGET/$module ./$module Debug "$module copied to initrd from target system" else Debug "did not find module $DIR_TARGET/$module to be copied to initrd" fi done if [ -s /etc/modules/options/$driver ]; then cp -a /etc/modules/options/$driver etc/modules/options Debug "/etc/modules/options/$driver copied to initrd" fi done else Debug "<$mod_file> not found" fi # copy module autoload routine cp -a /etc/rc.d/rc.rootfs etc/rc.d # this is used to trigger a initrd umount and freeramdisk in rc.boot touch free_initrd # create a very simple linuxrc echo '#!/bin/sh' > linuxrc echo "/bin/sh /etc/rc.d/rc.rootfs" >> linuxrc echo "exit 0" >> linuxrc chmod 755 linuxrc } # # create compressed initrd image using the loop mount # Create_Initrd() { local LoopFile=$DIR_TARGET/tmp/loopfile local LoopFileSize=2880 local LoopMountPoint=$DIR_TARGET/mnt local InitrdImage=$DIR_TARGET/boot/initrd.gz Do_Clear_Screen echo "Preparing initrd..." echo prep_use LOOP prep_use PREPARE # load loop support Do_Load_Module --silent loop block # clear loopfile dd if=/dev/zero of=$LoopFile bs=1k count=$LoopFileSize # create loop device if necessary if [ ! -b /dev/loop0 ]; then mknod -m 666 /dev/loop0 b 7 0 fi # prepare loop file for mount losetup /dev/loop0 $LoopFile # create filesystem on loopfile mke2fs /dev/loop0 $LoopFileSize echo echo "Please wait..." # mount loopfile as block device (needs mount >= 2.5k) mount -t ext2 /dev/loop0 $LoopMountPoint # create a minimal initrd for this system ( cd $LoopMountPoint ; Prepare_Initrd ) # unmount it umount /dev/loop0 # create compressed initrd from it dd if=/dev/loop0 bs=1k count=$LoopFileSize | gzip -9 > $InitrdImage # detach it losetup -d /dev/loop0 # remove loopfile rm -f $LoopFile # unload loop support rmmod loop # FIXME: add it as default LILO entry # currently we trigger if a $DIR_TARGET/boot/initrd.gz is present end_use LOOP end_use PREPARE sleep 3 } Is_SCSI_Root() { local root_dev="`Get_Val CONF_INSTALL_ROOT`" echo "$root_dev" | fgrep "/dev/sd" > /dev/null && return 0 return 1 } # check if we use an ethercard Is_Etherhost() { cat /proc/net/dev | fgrep eth0 > /dev/null && return 0 return 1 } Set_initrd() { local need_initrd= Is_SCSI_Root && need_initrd=true # Is_Etherhost && need_initrd=true if [ -n "$need_initrd" ]; then # we need a initrd Create_Initrd else # we don't need a initrd rm -fr $DIR_TARGET/initrd/* fi return 0 } Set_modules_autoload() { local uname_r="`Get_uname_r`" local uname_v="`Get_uname_v`" local confpath="/etc/modules/${uname_r}" local driver local mod_file local param_file # modules loaded by LISA were stored in this file local lisa_modules_file=/tmp/modules.initrd touch $lisa_modules_file # modules already handled will be stored in this file local handled_modules_file=$DIR_TARGET/tmp/modules.handled mkdir -p $DIR_TARGET/tmp rm -f $handled_modules_file touch $handled_modules_file # modules needed for the rootfs will be stored in this file # FIXME12uname: because of the rebuild uname -v causes problems local rootfs_modules_file="$DIR_TARGET$confpath/${uname_v}.rootfs" rm -f "$rootfs_modules_file" touch "$rootfs_modules_file" # modules needed for everything but the rootfs will be stored in this file # FIXME12uname: because of the rebuild uname -v causes problems local non_rootfs_modules_file="$DIR_TARGET$confpath/${uname_v}.default" mkdir -p $DIR_TARGET/etc/modules/options mkdir -p $DIR_TARGET$confpath rm -f "$non_rootfs_modules_file" touch "$non_rootfs_modules_file" # The list of modules to be autoloaded consists of 3 parts: # 1. modules loaded by LISA (during autoprobing and on user's request) local lisa_modules="`cat $lisa_modules_file`" # 2. modules that are loaded now (that we don't miss manually loaded modules) local loaded_modules="`cat /proc/modules | cut -d' ' -f 1`" # 3. modules that we want always to be loaded local default_modules="sunrpc lockd fat msdos umsdos vfat parport parport_pc parport_probe soundcore soundlow 8390 scsi_mod sd_mod sr_mod st sg nfs isofs lp slhc slip ppp ipx" # The modules may be autoloaded in 2 steps: # 1. modules required to load the root filesystem thus loaded in the initrd # (this is only necessary if ethercard used or rootfs on a SCSI device) local need_initrd= # 2. other modules # check if rootfs on SCSI Is_SCSI_Root && need_initrd=true # check if we use an ethercard # FIXME: we don't support NFS mounted root at the moment # Is_Etherhost && need_initrd=true # store modules and their params in the appropriate autoload files for driver in $lisa_modules $loaded_modules $default_modules ; do if [ -n "`fgrep -x $driver "$handled_modules_file"`" ]; then Debug "'$driver' is already handled" continue fi echo "$driver" >> "$handled_modules_file" Debug "added '$driver' to '$handled_modules_file'" mod_file="$non_rootfs_modules_file" param_file="$DIR_TARGET/etc/modules/options/$driver" if [ -n "$need_initrd" ]; then # FIXME: this is a dumb check for scsi driver (should be done by sysinfo) if [ -f /lib/modules/`uname -r`/scsi/$driver.o ]; then mod_file="$rootfs_modules_file" fi # FIXME: this is a dumb check for ether driver (should be done by sysinfo) # FIXME: we don't support NFS mounted root at the moment #if [ -f /lib/modules/${uname_r}/net/$driver.o ]; then # mod_file="$rootfs_modules_file" #fi fi echo "$driver" >> "$mod_file" Debug "added '$driver' to '$mod_file'" if [ -s /etc/modules/options/$driver ]; then Debug "added '`cat /etc/modules/$driver`' to '$param_file'" cp -a /etc/modules/options/$driver $param_file fi done } Set_etc_HOSTNAME() { local conf_file=$DIR_TARGET/etc/HOSTNAME mkdir -p $DIR_TARGET/etc echo "`Get_Val CONF_FQ_HOSTNAME`" > $conf_file } Set_keyboard() { local conf_file=$DIR_TARGET/etc/sysconfig/keyboard echo "KEYTABLE=`Get_Val CONF_KEYBOARD_MAP`" > $conf_file } Set_clock() { local conf_file=$DIR_TARGET/etc/sysconfig/clock local timezone="`Get_Val CONF_TIMEZONE`" local zoneinfo_dir=/usr/share/zoneinfo mkdir -p $DIR_TARGET/etc/sysconfig if [ "`Get_Val CONF_KERNTZ_FLAG`" = "u" ]; then echo "CLOCKMODE=GMT" > $conf_file else echo "CLOCKMODE=LOCAL" > $conf_file fi if [ -z "$timezone" ]; then timezone=GMT fi if [ ! -d $DIR_TARGET$zoneinfo_dir ]; then zoneinfo_dir=/usr/lib/zoneinfo fi # fix symlink only if it's NOT pointing relative to /etc/localtime if [ -z "`ls -l ${DIR_TARGET}${zoneinfo_dir}/localtime | fgrep ' ../../../etc/localtime'`" ]; then ln -sf ../../../etc/localtime ${DIR_TARGET}${zoneinfo_dir}/localtime fi rm -f $DIR_TARGET/etc/localtime mkdir -p $DIR_TARGET/etc ln -sf ..${zoneinfo_dir}/$timezone $DIR_TARGET/etc/localtime } Set_pcmcia() { local conf_file=$DIR_TARGET/etc/sysconfig/pcmcia # check if we used pcmcia during install # (in this case some modules were loaded from rc.S) if [ -n "`fgrep pcmcia_core /proc/modules`" ]; then echo "PCMCIA=yes" > $conf_file if [ -n "`fgrep i82365 /proc/modules`" ]; then echo "PCIC=i82365" >> $conf_file elif [ -n "`fgrep tcic /proc/modules`" ]; then echo "PCIC=tcic" >> $conf_file else # ??? shouldn't happpen echo "PCIC=" >> $conf_file fi else echo "PCMCIA=no" > $conf_file echo "PCIC=" >> $conf_file fi echo "OPTS=\"poll_interval=300\"" >> $conf_file } Set_network() { local conf_file=$DIR_TARGET/etc/sysconfig/network mkdir -p $DIR_TARGET/etc/sysconfig echo "NETWORKING=yes" > $conf_file echo "HOSTNAME=`Get_Val CONF_FQ_HOSTNAME`" >> $conf_file echo "IF_LIST='lo eth tr sl ppp'" >> $conf_file } Set_ifcfg() { local dev=$1 local val= local conf_file=$DIR_TARGET/etc/sysconfig/network-scripts/ifcfg-${dev} mkdir -p $DIR_TARGET/etc/sysconfig/network-scripts echo '#!/bin/sh' > $conf_file case $dev in eth0|eth1) echo '#>>>Device type: ethernet' >> $conf_file ;; tr0) echo '#>>>Device type: token ring' >> $conf_file ;; plip0|plip1|plip2) echo '#>>>Device type: parallel line IP' >> $conf_file ;; esac echo '#>>>Variable declarations:' >> $conf_file echo "DEVICE=`Get_Val CONF_${dev}_DEV`" >> $conf_file echo "IPADDR=`Get_Val CONF_${dev}_IP`" >> $conf_file if [ -n "`Get_Val CONF_${dev}_REMOTE_IP`" ]; then echo "PTPADDR=`Get_Val CONF_${dev}_REMOTE_IP`" >> $conf_file if [ "`echo $dev | cut -c1-4`" = "plip" ]; then cat << EOF >> $conf_file # for communication with DOS boxes turn activate #IFOPTIONS="arp" EOF fi fi echo "NETMASK=`Get_Val CONF_${dev}_MASK`" >> $conf_file echo "NETWORK=`Get_Val CONF_${dev}_NET`" >> $conf_file echo "BROADCAST=`Get_Val CONF_${dev}_BCAST`" >> $conf_file if [ "$dev" = "eth0" -o "`echo $dev | cut -c1-4`" = "plip" ]; then if [ -z "`Get_Val CONF_ROUTER1_IP`" ]; then echo "GATEWAY=none" >> $conf_file else echo "GATEWAY=`Get_Val CONF_ROUTER1_IP`" >> $conf_file fi else echo "GATEWAY=none" >> $conf_file fi if [ "`Get_Val CONF_${dev}_STAT`" = "up" ]; then echo "ONBOOT=yes" >> $conf_file else echo "ONBOOT=no" >> $conf_file fi echo '#>>>End variable declarations' >> $conf_file chmod 755 $conf_file } Fix_basename() { # FIXME: (ugly) overwrite the a.out binary with the ELF version if [ -f $DIR_TARGET/usr/bin/basename ]; then cp -af $DIR_TARGET/usr/bin/basename $DIR_TARGET/bin/basename else if [ ! -f $DIR_TARGET/bin/basename ]; then if [ -f /bin/basename ]; then cp -af /bin/basename $DIR_TARGET/bin/basename fi fi fi } Fix_Obsolete_Progs() { local i Fix_basename # remove obsolete progies from /root for i in floppy README bin/rpmq ; do rm -fr $DIR_TARGET/$i done # remove obsolete libs from /root rm -f $DIR_TARGET/lib/libc.so.4 rm -f $DIR_TARGET/lib/libc.so.4.5.24 } Fix_conf_getty() { local conf_file=/etc/conf.getty # disable getty's clear-screen behaviour if [ ! -f $DIR_TARGET$conf_file ]; then echo "CLEAR=NO" > $DIR_TARGET$conf_file chmod 644 $DIR_TARGET$conf_file fi } Fix_rc_sysinit() { local conf_file=/etc/rc.d/rc.sysinit # autoload the default modules if [ -z "`fgrep rc.modules $DIR_TARGET$conf_file`" ]; then cat << 'EOF' >> $DIR_TARGET$conf_file # Autoload the default modules if [ -f /etc/rc.d/rc.modules ]; then /etc/rc.d/rc.modules fi EOF fi } # try to detect broken insmod by gzip's CRC and replace it. # Fix_Broken_Insmod() { local badcsum if [ -f $DIR_TARGET/sbin/insmod ]; then cp -a $DIR_TARGET/sbin/insmod $DIR_TARGET/tmp/insmod gzip -9f $DIR_TARGET/tmp/insmod badcsum="`gzip -lv $DIR_TARGET/tmp/insmod.gz | fgrep insmod | cut -c 7-14`" if [ "$badcsum" = "51763471" -o "$badcsum" = "2eca023d" ]; then Debug "broken insmod detected and replaced" cp -a /sbin/insmod $DIR_TARGET/sbin/insmod else Debug "CRC of insmod doesn't match broken one" fi rm -f $DIR_TARGET/tmp/insmod.gz else Debug "no insmod found" fi } # fix /etc/fstab # Fix_etc_fstab() { local conf_file=$DIR_TARGET/etc/fstab local cd_dev="`Get_Val CONF_CD1_DEV`" # add floppy and cdrom entries in fstab mkdir -p $DIR_TARGET/mnt/floppy mkdir -p $DIR_TARGET/mnt/cdrom cat << 'EOF' >> $conf_file # /dev/fd0 /mnt/floppy msdos defaults,user,noauto 0 0 # EOF if [ -n "$cd_dev" ]; then echo "$cd_dev /mnt/cdrom iso9660 ro,user,noauto 0 0" >> $conf_file fi } Fix_ldconfig() { export PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin" if [ ! -f /sbin/ldconfig ]; then ln -s $DIR_TARGET/sbin/ldconfig /sbin/ldconfig Debug "creating symlink for /sbin/ldconfig" fi #Debug "running 'chroot $DIR_TARGET ldconfig -X'" #chroot $DIR_TARGET ldconfig -X Debug "running 'chroot $DIR_TARGET sbin/ldconfig'" ( cd $DIR_TARGET; chroot $DIR_TARGET sbin/ldconfig ) > $DIR_TARGET/tmp/ldconfig.out 2>&1 } Fix_lilo() { local i prep_use LILO for i in /sbin/lilo /sbin/activate /boot/boot.b /boot/message /boot/any_b.b /boot/any_d.b /boot/os2_d.b /boot/chain.b /etc/lilo.conf.in ; do if [ -f $i.gz ]; then gzip -df $i fi if [ "$CND10_MODE" = "true" ]; then if [ -f $i ]; then cp -a $i $DIR_TARGET$i fi fi done } Fix_procps() { local i for i in /bin/ps /bin/kill ; do if [ -f $i ]; then cp -a $i $DIR_TARGET$i fi done } Set_Resolver() { local i for i in $FILE_ETC_HOSTS $FILE_ETC_RESOLV_CONF ; do if [ -f $i ]; then cp -a $i $DIR_TARGET$i fi done } Fix_freeramdisk() { if [ "$CND10_MODE" = "true" ]; then # make sure the initrd will be saved and freeramdisk called if [ -f /etc/rc.d/rc.free ]; then cp -a /etc/rc.d/rc.free $DIR_TARGET/etc/rc.d/rc.free cat << EOF >> $DIR_TARGET/etc/rc.d/rc.local if [ -x /etc/rc.d/rc.free ]; then /etc/rc.d/rc.free fi EOF fi if [ ! -f /root/bin/freeramdisk ]; then if [ -f /bin/freeramdisk.gz ]; then cp -a /bin/freeramdisk.gz /root/bin gzip -df /root/bin/freeramdisk.gz fi fi fi } Fix_Missing_Root() { mkdir -p $DIR_TARGET/root } # FIXME: obsolete now? Fix_faked_lib_versions() { if [ ! -f $DIR_TARGET/usr/lib/libdb.so.2 ]; then ln -s libdb.so.1 $DIR_TARGET/usr/lib/libdb.so.2 Debug "Fixing libdb symlink" fi } Fix_news() { echo "IDENT=news-system" > $DIR_TARGET/etc/sysconfig/daemons/news echo "ONBOOT=no" >> $DIR_TARGET/etc/sysconfig/daemons/news chmod 644 $DIR_TARGET/etc/sysconfig/daemons/news } # FIXME: is now in skeleton.cgz but still necessary for LST 2.2 install Fix_daemons() { mkdir -p $DIR_TARGET/etc/sysconfig/daemons } Fix_3c59x() { if [ -f /lib/modules/2.0.21/net/3c59x.o.gz ]; then gzip -df /lib/modules/2.0.21/net/3c59x.o.gz fi if [ -f /lib/modules/2.0.21/net/3c59x.o ]; then cp -af /lib/modules/2.0.21/net/3c59x.o $DIR_TARGET/lib/modules/2.0.21/net fi } Fix_DEV() { if [ ! -b $DIR_TARGET/dev/cdu31a ]; then if [ -b $DIR_TARGET/dev/sonycd ]; then cp -a $DIR_TARGET/dev/sonycd $DIR_TARGET/dev/cdu31a fi fi } Fix_runlevel() { # With COL 2.2 the default runlevel is 5, but with the lisa install # X is not configured yet, so we must set the default runlevel to 3 sed 's/^id:5:initdefault:/id:3:initdefault:/' $DIR_TARGET/etc/inittab > $DIR_TARGET/etc/inittab.tmp mv $DIR_TARGET/etc/inittab.tmp $DIR_TARGET/etc/inittab chmod 644 $DIR_TARGET/etc/inittab } Fix_shadow22() { sed 's/:0::7:7::/:0:365:7:7::/' $DIR_TARGET/etc/shadow > $DIR_TARGET/etc/shadow.tmp mv $DIR_TARGET/etc/shadow.tmp $DIR_TARGET/etc/shadow chmod 600 $DIR_TARGET/etc/shadow } Do_Fixes_After_First_Config() { Info ":INFO_COPYING_FILES_TO_TARGET:" Set_LISA_CONF Transfer_dev_symlinks Fix_Missing_Root Fix_Broken_Insmod mkdir -p /etc/sysconfig mkdir -p /etc/sysconfig/network-scripts mkdir -p /etc/rc.d/init.d Set_etc_HOSTNAME Set_keyboard Set_pcmcia Set_network Set_ifcfg eth0 Set_ifcfg tr0 # Fix_conf_getty Fix_etc_fstab Set_Resolver Fix_faked_lib_versions Fix_Obsolete_Progs Fix_ldconfig if [ "$CND10_MODE" = "true" ]; then Fix_freeramdisk Fix_rc_sysinit Fix_procps fi Fix_news Fix_3c59x Fix_DEV Do_Setup_teTeX Do_Setup_locate Fix_tmp_area Fix_uucp Fix_runlevel Fix_shadow22 Finish_unconfigured_sh } Fix_tmp_area() { mkdir -p $DIR_TARGET/tmp chmod 1777 $DIR_TARGET/tmp Debug "Fixing mode of tmp area" } Create_fsstnd() { # FIXME: should be created by a fsstnd pkg mkdir -p $DIR_TARGET/tmp chmod 1777 $DIR_TARGET/tmp mkdir -p $DIR_TARGET/boot mkdir -p $DIR_TARGET/etc mkdir -p $DIR_TARGET/mnt mkdir -p $DIR_TARGET/usr #( cd $DIR_TARGET/usr ; ln -sf ../var/spool spool ) #mkdir -p $DIR_TARGET/var/spool/lpd #mkdir -p $DIR_TARGET/var/spool/mail #mkdir -p $DIR_TARGET/var/spool/news #mkdir -p $DIR_TARGET/var/spool/uucp } Transfer_LISA() { local i local binaries_from_floppy if [ "$CND10_MODE" = "true" ]; then binaries_from_floppy="box build_menu db_printf do_calc do_echo do_netcalc do_quote filesize get_info get_key get_val hilfe lisa prep_use set_val sysinfo rpmq" else binaries_from_floppy="filesize hilfe lisa prep_use" fi # init LISA tmp area mkdir -p $DIR_TARGET/tmp/LST chmod 1777 $DIR_TARGET/tmp # init LISA install area # be backward compatible to old LST install directory mkdir -p $DIR_TARGET/var/lib/LST mkdir -p $DIR_TARGET/var/lib/LST/log mkdir -p $DIR_TARGET/var/lib/LST/analyse rm -fr $DIR_TARGET/install ln -sf var/lib/LST $DIR_TARGET/install echo "$CONF_LST_VERSION" > $DIR_TARGET/install/BASEVERSION if [ -d /var/lib/LST ]; then cp -aR /var/lib/LST $DIR_TARGET/var/lib fi # copy LISA doc area mkdir -p $DIR_TARGET/usr/doc/LST cp -aR /floppy/usr/doc/LST/* /usr/doc/LST/* /source/doc/LST/* $DIR_TARGET/usr/doc/LST gzip -df $DIR_TARGET/usr/doc/LST/*.gz if [ "$INSTALL_MODE" = "LST" ]; then # to make sure they are read ;-) for i in COPYING CREDITS README.1st ; do if [ -f $DIR_TARGET/usr/doc/LST/$i ]; then ln -s usr/doc/LST/$i $DIR_TARGET/$i fi done fi # copy LISA lib area mkdir -p $DIR_TARGET/usr/lib/LST cp -a /usr/lib/LST/smarties $DIR_TARGET/usr/lib/LST cp -a /usr/lib/LST/IDENTIFY $DIR_TARGET/usr/lib/LST/IDENTIFY.root if [ -f /floppy/IDENTIFY ]; then cp -a /floppy/IDENTIFY $DIR_TARGET/usr/lib/LST/IDENTIFY.boot fi echo "`uname -a`" > $DIR_TARGET/usr/lib/LST/IDENTIFY.kernel for i in libLSTall meta.db pkgs.db pkgs.idx ; do if [ -f /usr/lib/LST/$i.gz ]; then cp -a /usr/lib/LST/$i.gz $DIR_TARGET/usr/lib/LST/$i.gz gzip -df $DIR_TARGET/usr/lib/LST/$i.gz elif [ -f /usr/lib/LST/$i ]; then cp -a /usr/lib/LST/$i $DIR_TARGET/usr/lib/LST/$i fi done cp -a /usr/lib/LST/libLSTtext $DIR_TARGET/usr/lib/LST/libLSTtext # copy LISA binary files from floppy to target mkdir -p $DIR_TARGET/bin # FIXME: no binaries at all should be copied from the install floppy for i in $binaries_from_floppy ; do if [ -f /bin/$i.gz ]; then cp -a /bin/$i.gz $DIR_TARGET/bin gzip -df $DIR_TARGET/bin/$i.gz elif [ -f /bin/$i ]; then cp -a /bin/$i $DIR_TARGET/bin fi done ( cd $DIR_TARGET/bin ; ln -sf prep_use end_use ) ( cd $DIR_TARGET/bin ; ln -sf prep_use not_use ) ( cd $DIR_TARGET/bin ; ln -sf prep_use show_use ) ( cd $DIR_TARGET/bin ; ln -sf lisa sysinstall ) ( cd $DIR_TARGET/bin ; ln -sf lisa syssetup ) ( cd $DIR_TARGET/bin ; ln -sf lisa netsetup ) # copy LISA config files Set_LISA_CONF } Transfer_RPM() { # init RPM area mkdir -p $DIR_TARGET/var/lib/rpm mkdir -p /var/lib ln -sf $DIR_TARGET/var/lib/rpm /var/lib/rpm } Transfer_kernel() { local i local kernel # copy kernel for i in $DIR_TARGET/floppy/vmlinuz* ; do if [ -f $i ]; then kernel=`basename $i` ln -f $i $DIR_TARGET/$kernel fi done # copy WHATSIN files mkdir -p $DIR_TARGET/boot for i in $DIR_TARGET/floppy/boot/WHATSIN* ; do if [ -f $i ]; then kernel=`basename $i` ln -f $i $DIR_TARGET/boot/$kernel fi done } Transfer_modules() { local i # copy modules mkdir -p $DIR_TARGET/lib/modules cp -aR /floppy/lib/modules/* /lib/modules/* $DIR_TARGET/lib/modules for i in $DIR_TARGET/lib/modules/`uname -r`/*/*.o.gz ; do if [ -f $i ]; then gzip -df $i fi done } Delete_unused_modules() { local i local modpath=/lib/modules/`uname -r` for i in $modpath/*/*.gz ; do rm -f $i done } Do_Switch_Log_Area() { Do_Log -f $FILE_LOG_HISTORY "`date` $LOGNAME: Moving log area to $DIR_TARGET" mkdir -p $DIR_TARGET/var/adm cp -aR /var/adm/LST $DIR_TARGET/var/adm rm -fr /var/adm/LST ln -s $DIR_TARGET/var/adm/LST /var/adm/LST } Transfer_root_floppy() { local i local kernel= local prefix= # copy LILO files mkdir -p $DIR_TARGET/floppy/boot for i in any_b.b any_d.b boot.b chain.b message os2_d.b ; do if [ -f /boot/$i ]; then cp -a /boot/$i $DIR_TARGET/floppy/boot fi if [ -f /floppy/boot/$i ]; then cp -a /floppy/boot/$i $DIR_TARGET/floppy/boot fi done mkdir -p $DIR_TARGET/floppy/sbin for i in activate lilo sysinstall mkfs.minix ; do if [ -f /sbin/$i.gz ]; then cp -a /sbin/$i.gz $DIR_TARGET/floppy/sbin gunzip -f $DIR_TARGET/floppy/sbin/$i.gz fi done mkdir -p $DIR_TARGET/floppy/etc if [ -f /etc/lilo.conf.in ]; then cp -a /etc/lilo.conf.in $DIR_TARGET/floppy/etc/lilo.conf fi # copy kernel for i in /vmlinuz* /floppy/vmlinuz* ; do if [ -f $i ]; then kernel=`basename $i` cp -a $i $DIR_TARGET/floppy/$kernel rdev $DIR_TARGET/floppy/$kernel $CONF_INSTALL_ROOT rdev -r $DIR_TARGET/floppy/$kernel 0 rdev -R $DIR_TARGET/floppy/$kernel 1 if [ "$DIR_TARGET" = "/root/linux" ]; then rdev -R $DIR_TARGET/floppy/$kernel 0 fi fi done if [ -f /boot/WHATSIN* ]; then cp -a /boot/WHATSIN* $DIR_TARGET/floppy/boot fi if [ -f /floppy/boot/WHATSIN* ]; then cp -a /floppy/boot/WHATSIN* $DIR_TARGET/floppy/boot fi # creating device files mkdir -p $DIR_TARGET/floppy/dev prefix=$DIR_TARGET/floppy/dev/ mknod -m 644 ${prefix}fd0 b 2 0 mknod -m 644 ${prefix}fd0h1200 b 2 8 mknod -m 644 ${prefix}fd0H1440 b 2 28 mknod -m 644 ${prefix}fd1 b 2 1 mknod -m 644 ${prefix}fd1h1200 b 2 9 mknod -m 644 ${prefix}fd1H1440 b 2 29 # chgrp root.disk ${prefix}fd* } Fix_apache() { # apache-httpd version 1.1.1-10 is broken and needs symlinks if [ -n "`fgrep apache-httpd $FILE_PKGS_DATA | fgrep '1.1.1-10'`" ]; then Debug "fixing broken apache-httpd-1.1.1-10 package..." mkdir -p $DIR_TARGET/home/httpd ln -s apache/html $DIR_TARGET/home/httpd/html ln -s apache/cgi-bin $DIR_TARGET/home/httpd/cgi-bin ln -s apache/icons $DIR_TARGET/home/httpd/icons fi } Fix_useradd() { # lisa-2.2-3 contains a broken useradd (creates "*" passwd entries) if [ -n "`fgrep lisa $FILE_PKGS_DATA | fgrep '2.2-3'`" ]; then if [ -r /usr/sbin/useradd.ELF.gz ]; then Debug "fixing broken lisa-2.2-3 package..." cp -af /usr/sbin/useradd.ELF.gz $DIR_TARGET/usr/sbin/useradd.gz gzip -df $DIR_TARGET/usr/sbin/useradd.gz chmod 755 $DIR_TARGET/usr/sbin/useradd fi fi } Fix_log_permissions() { touch $DIR_TARGET/var/log/messages chmod 600 $DIR_TARGET/var/log/messages touch $DIR_TARGET/var/log/secure chmod 600 $DIR_TARGET/var/log/secure } Fix_rc_modules() { sed '/^ insmod/s/\"//g' < $DIR_TARGET/etc/rc.d/rc.modules > $DIR_TARGET/etc/rc.d/rc.modules.tmp chmod 755 $DIR_TARGET/etc/rc.d/rc.modules.tmp mv $DIR_TARGET/etc/rc.d/rc.modules.tmp $DIR_TARGET/etc/rc.d/rc.modules } Do_Init_Target() { local i local kernel= local prefix= Info ":INFO_COPYING_FILES_TO_TARGET:" Create_fsstnd Transfer_LISA Transfer_RPM Transfer_root_floppy Transfer_kernel Transfer_modules Set_modules_autoload Fix_12_Alpha target_mounted Set_initrd # FIXME: for debugging only # trigger a copy of the initrd we used for install under /var/tmp/initrd # touch /save_initrd # trigger a initrd umount and freeramdisk in rc.boot touch /free_initrd Set_message Fix_lilo Fix_daemons Fix_apache # FIXME: need better method to find initrd if [ "`uname -r`" != "1.2.13" ]; then mkdir -p $DIR_TARGET/initrd Set_Real_Root $CONF_INSTALL_ROOT fi # this is to support RPM 2.2.x mkdir -p $DIR_TARGET/etc # if [ "$DIR_TARGET" != "/" ]; then # cp -a /etc/passwd $DIR_TARGET/etc/passwd # cp -a /etc/group $DIR_TARGET/etc/group # # we bring a rpmrc for 2.2 with us on the floppy # # check if we have for newer ones # if [ -f /source/lib/rpmrc-2.5 ]; then # ln -s /source/lib/rpmrc-2.5 /usr/lib/rpmrc-2.5 # elif [ -f /source/lib/rpmrc-2.4 ]; then # ln -s /source/lib/rpmrc-2.4 /usr/lib/rpmrc-2.4 # fi # fi ROOT_INITIALIZED=1 return 0 } Fix_i386_RPMS() { if [ "$INSTALL_MODE" != "OpenLinux" ]; then mkdir -p $DIR_TARGET/usr/src/redhat/RPMS/i386 fi } Fix_SuperProbe() { # security fix chmod -s $DIR_TARGET/usr/X11R6/bin/SuperProbe } Fix_root_dotfiles() { mkdir -p $DIR_TARGET/root cp -aR $DIR_TARGET/etc/skel/.??* $DIR_TARGET/root } Fix_etc_login_defs() { if [ -f $DIR_TARGET/etc/login.defs ]; then sed 's/^HOME \/home/HOME \/home\/%s/' $DIR_TARGET/etc/login.defs > $DIR_TARGET/etc/login.defs.tmp mv $DIR_TARGET/etc/login.defs.tmp $DIR_TARGET/etc/login.defs chmod 640 $DIR_TARGET/etc/login.defs fi } Fix_usr_info_dir_gz() { # this file is not necessary and makes xeamcs really unhappy, so remove it if [ -f $DIR_TARGET/usr/info/dir.gz ]; then rm -f $DIR_TARGET/usr/info/dir.gz fi } Do_Fixes_After_Pkg_Install() { Fix_sendmail_start Fix_httpd_start Fix_i386_RPMS Fix_SuperProbe Fix_rc_modules Fix_useradd Fix_log_permissions Fix_root_dotfiles Fix_etc_login_defs Fix_usr_info_dir_gz } # libLSTmodule - module handling library shared between several scripts # # Copyright (C) 1993-1997 Ralf Flaxa, LST Software GmbH, Erlangen, Germany # Show_Kernel_Whatsin() { if [ ! -f $1 ]; then Error "$1: file not found" return 1 fi Browse2 $1 KERNEL_WHATSIN return 0 } Menu_Config_Kernel() { local item # "CREATE" ":MENU_CREATE_KERNEL:" while [ 1 ]; do $CMD_BOX --help ":MENU_CONFIG_KERNEL_HELP:" \ --default "$item" \ --title ":MENU_CONFIG_KERNEL_TITLE:" \ --menu ":MENU_CONFIG_KERNEL_TEXT:" \ "WHATSIN" ":INFO_KERNEL_WHATSIN:" \ "LOADED" ":MENU_MODULE_SHOW_LOADED:" \ "REMOVE" ":MENU_MODULE_REMOVE:" \ "AVAILABLE" ":MENU_MODULE_SHOW_AVAILABLE:" \ "LOAD" ":MENU_MODULE_LOAD:" 2> $FILE_TMP_ANSWER || break item="`cat $FILE_TMP_ANSWER`" case $item in WHATSIN) Show_Kernel_Whatsin /boot/WHATSIN-`uname -r`-modular ;; LOADED) Menu_Module_Show_Loaded ;; REMOVE) Menu_Module_Remove ;; AVAILABLE) Menu_Module_Show_Available ;; LOAD) Menu_Module_Load ;; CREATE) Do_Create_New_Kernel ;; esac done return 0 } List_MODULES_LOADED() { lsmod | fgrep -v "#pages" } Build_MODULES_LOADED() { List_MODULES_LOADED | do_quote } List_MODULES_AVAILABLE() { local module= for module in /floppy/lib/modules/`uname -r`/*/*.o ; do if [ -f $module ]; then echo "`basename $module .o`" fi done for module in /floppy/lib/modules/`uname -r`/*/*.o.gz ; do if [ -f $module ]; then echo "`basename $module .o.gz`" fi done for module in /lib/modules/`uname -r`/*/*.o ; do if [ -f $module ]; then echo "`basename $module .o`" fi done for module in /lib/modules/`uname -r`/*/*.o.gz ; do if [ -f $module ]; then echo "`basename $module .o.gz`" fi done } Build_MODULES_AVAILABLE() { List_MODULES_AVAILABLE | do_quote } Menu_Module_Load() { Choose --menutitle ":INFO_MODULES_LOADED_MENUTITLE:" --build Build_MODULES_AVAILABLE MODULE_LOAD || return 1 if [ -z "$ANSWER" ]; then Error "no module specified" return 1 fi Do_Load_Module "$ANSWER" || return 1 return 0 } Menu_Module_Remove() { Choose --menutitle ":INFO_MODULES_LOADED_MENUTITLE:" --build Build_MODULES_LOADED MODULE_REMOVE || return 1 if [ -z "$ANSWER" ]; then Error "no module specified" return 1 fi rmmod $ANSWER || return 1 return 0 } Menu_Module_Show_Loaded() { List_MODULES_LOADED > $FILE_TMP_MSG 2> $FILE_TMP_ERR if [ -s $FILE_TMP_ERR ]; then Error --file $FILE_TMP_ERR return 1 fi if [ ! -s $FILE_TMP_MSG ]; then Msg ":INFO_NO_MODULES_LOADED:" else $CMD_BOX --help ":HELP_MODULES:" \ --title ":INFO_MODULES_LOADED_TITLE:" \ --menutitle ":INFO_MODULES_LOADED_MENUTITLE:" \ --text ":INFO_MODULES_LOADED_TEXT:" --browse $FILE_TMP_MSG fi } Menu_Module_Show_Available() { List_MODULES_AVAILABLE > $FILE_TMP_MSG 2> $FILE_TMP_ERR if [ -s $FILE_TMP_ERR ]; then Error --file $FILE_TMP_ERR return 1 fi if [ ! -s $FILE_TMP_MSG ]; then Msg ":INFO_NO_MODULES_AVAILABLE:" else $CMD_BOX --help ":HELP_MODULES:" \ --title ":INFO_MODULES_AVAILABLE_TITLE:" \ --text ":INFO_MODULES_AVAILABLE_TEXT:" --browse $FILE_TMP_MSG fi } Do_Load_Driver() { local present=0 local test_only= local silent_flag= local module_name= local module_type= if [ $# -gt 0 -a "$1" = '--test' ]; then test_only=true shift 1 fi if [ $# -ne 2 ]; then Panic ":ERR_WRONG_NUM_OF_ARGS: ($#)" || return 1 fi case $1 in # filesystems filesystem) module_type=fs silent_flag='--silent' sysinfo --var --kernel 2>&1 >/dev/null | fgrep "INFO_FILESYSTEMS" > $FILE_TMP_MSG fgrep ":$2:" $FILE_TMP_MSG >/dev/null && return 0 case $2 in nfs|hpfs|msdos|umsdos) module_name="$2" ;; iso9660) module_name="isofs" ;; esac ;; # CDROMs cdrom) module_type=misc sysinfo >/dev/null --var --cdrom 2> $FILE_TMP_MSG sed 's:/dev/sr:/dev/scd:' < $FILE_TMP_MSG | fgrep ":$2:" >/dev/null if [ $? -eq 0 ]; then return 0 fi case $2 in /dev/arcd) module_name="arcd" ;; /dev/aztcd) module_name="aztcd" ;; /dev/bpcd) module_name="bpcd" ;; /dev/bpmcd) module_name="bpmcd" ;; /dev/cdu31a) module_name="cdu31a" ;; /dev/cdu535) module_name="sonycd535" ;; /dev/cm206cd) module_name="cm206" ;; /dev/dscd) module_name="dscd" ;; /dev/epcd) module_name="epcd" ;; /dev/gscd) module_name="gscd" ;; /dev/kicd) module_name="kicd" ;; /dev/oicd) module_name="oicd" ;; /dev/optcd) module_name="optcd" ;; /dev/mcd) module_name="mcd" ;; /dev/mcdx) module_name="mcdx" ;; /dev/pwcd) module_name="pwcd" ;; /dev/sbpcd) module_name="sbpcd" ;; /dev/sbpcd0) module_name="sbpcd" ;; /dev/sjcd) module_name="sjcd" ;; /dev/sonycd) module_name="cdu31a" ;; *) module_name="" ;; esac ;; ether) module_type=net silent_flag='--silent' sysinfo >/dev/null --var --ether 2> $FILE_TMP_MSG fgrep ":$2:" $FILE_TMP_MSG >/dev/null && return 0 return 1 ;; esac if [ -n "$test_only" ]; then return 1 fi if [ -z "$module_name" ]; then if [ "$1" = "cdrom" ]; then echo "$2" | fgrep /dev/hd >/dev/null 2>&1 if [ $? -eq 0 ]; then # has to be an ATAPI CDROM... return 0 fi fi $CMD_BOX --msg "$2 ; :ERR_NO_DEVICE_AND_NO_MODULE:" return 1 else Do_Load_Module $silent_flag $module_name $module_type retval=$? end_use /lib/modules/`uname -r`/$module_type/$module_name.o fi return $retval } Do_Load_Module() { local silent_flag= local modpath= local subpath= local module= local modparam= local param= if [ $# -gt 0 -a "$1" = '--silent' ]; then silent_flag=true shift 1 fi if [ $# -gt 1 -a "$1" = '--param' ]; then param="$2" shift 2 fi if [ $# -lt 1 ]; then Panic ":ERR_INVALID_PARAMS:" ; fi # check whether it's already loaded lsmod | sed -n "/^$1/p" > $FILE_TMP_ANSWER if [ -s $FILE_TMP_ANSWER ]; then Debug "Module $1 seems to be loaded..." return 0 else Debug "Module $1 is not loaded..." fi if [ -n "$param" ]; then modparam="$param" else # initialize with boot params if [ -s $FILE_BOOT_PARAMS ]; then Debug "Search for boot param <$1> in <$FILE_BOOT_PARAMS>..." sed -n "/^$1=/p" $FILE_BOOT_PARAMS > $FILE_TMP_ANSWER modparam="`cat $FILE_TMP_ANSWER`" Debug "found boot param <$modparam>" fi fi # check whether it's available modpath=/lib/modules/`uname -r` for subpath in $2 block cdrom fs ipv4 misc net pcmcia scsi ; do module="$modpath/$subpath/$1.o" if [ -s $module ]; then break elif [ -s ${module}.gz ]; then gzip -df ${module}.gz && break elif [ -s /source${module} ]; then ln -sf /source${module} $module && break elif [ -s /floppy${module}.gz ]; then gzip -dc /floppy${module}.gz > $module && break fi module= done if [ -z "$module" ]; then $CMD_BOX --msg "module $1.o ; :ERR_MODULE_NOT_AVAILABLE:" return 1 fi while [ 1 ]; do # dirty hack to adjust symbol names used for modules echo $modparam | sed '{ s/^cm206=/cm206_base=/ s/^gscd=/gscd_port=/ s/^sonycd535=/sony535_cd_base_io=/ }' > $FILE_TMP_ANSWER modparam="`cat $FILE_TMP_ANSWER`" if [ -z "$silent_flag" ]; then Info "module $1.o ; :INFO_MODULE_LOADING:" fi insmod $module $modparam >$FILE_TMP_ERR 2>&1 && break $CMD_BOX --msg "module $1.o ; :ERR_MODULE_LOADING_FAILED:" rmmod $1 >/dev/null 2>&1 Ask_String BOOT_PARAM $modparam || return 1 modparam="$ANSWER" if [ -z "$modparam" ]; then return 1 ; fi done echo "$1" >> /tmp/modules mkdir -p /etc/modules/options if [ -n "$modparam" ]; then echo "$modparam" > /etc/modules/options/$1 else rm -f /etc/modules/options/$1 fi return 0 } Do_Unload_Module() { local f_name=Do_Unload_Module local f_args=1 # (modulename) -> Check_Args $f_name $f_args $# "$@" || return 255 Debug "unloading module $1 ..." Info "module $1.o ; :INFO_MODULE_UNLOADING:" rmmod $1 && return 0 return 1 } # libLSTnet - network handling library shared between several scripts # # Copyright (C) 1993-1997 Ralf Flaxa, LST Software GmbH, Erlangen, Germany # Do_Ifcfg() { local interface="$1" local action="$2" Debug "Do_Ifcfg called with <$1> <$2>" case $interface in lo) Do_Ifcfg_lo $action ;; eth0) Do_Ifcfg_eth 0 $action ;; eth1) Do_Ifcfg_eth 1 $action ;; tr0) Do_Ifcfg_tr 0 $action ;; plip0) Do_Ifcfg_plip 0 $action ;; plip1) Do_Ifcfg_plip 1 $action ;; plip2) Do_Ifcfg_plip 2 $action ;; default) Do_Ifcfg_default $action ;; esac } Do_Ifcfg_default() { local router="`Get_Val CONF_ROUTER1_IP`" # route del default if [ "$1" = "up" ]; then if [ -n "$router" ]; then Debug "route add default gw $router" route add default gw $router fi fi } Do_Ifcfg_plip() { local num="$1" local plipx="plip${num}" local ip="`Get_Val CONF_${plipx}_IP`" local remote_ip="`Get_Val CONF_${plipx}_REMOTE_IP`" Debug "Debug: Do_Ifcfg_plip $1 $2" Debug "Debug: net = <$net>" # ifconfig $plipx down # route del -net $net if [ "$2" = "up" ]; then Debug "bringing up interface" Debug "ifconfig $plipx $ip pointopoint $remote_ip" ifconfig $plipx $ip pointopoint $remote_ip Debug "route add -host $remote_ip gw $ip" route add -host $remote_ip gw $ip fi } Do_Ifcfg_tr() { local num="$1" local trx="tr${num}" local ip="`Get_Val CONF_${trx}_IP`" local net="`Get_Val CONF_${trx}_NET`" local mask="`Get_Val CONF_${trx}_MASK`" local bcast="`Get_Val CONF_${trx}_BCAST`" Debug "Debug: Do_Ifcfg_tr $1 $2" Debug "Debug: net = <$net>" # ifconfig $trx down # route del -net $net if [ "$2" = "up" ]; then Debug "bringing up interface $trx" Debug "ifconfig $trx $ip netmask $mask broadcast $bcast" ifconfig $trx $ip netmask $mask broadcast $bcast Debug "route add -net $net" route add -net $net fi } Do_Ifcfg_eth() { local num="$1" local ethx="eth${num}" local ip="`Get_Val CONF_${ethx}_IP`" local net="`Get_Val CONF_${ethx}_NET`" local mask="`Get_Val CONF_${ethx}_MASK`" local bcast="`Get_Val CONF_${ethx}_BCAST`" Debug "Debug: Do_Ifcfg_eth $1 $2" Debug "Debug: net = <$net>" # ifconfig $ethx down # route del -net $net if [ "$2" = "up" ]; then Debug "bringing up interface $ethx" Debug "ifconfig $ethx $ip netmask $mask broadcast $bcast" ifconfig $ethx $ip netmask $mask broadcast $bcast Debug "route add -net $net" route add -net $net fi } Do_Ifcfg_lo() { # ifconfig lo down # route del -net 127.0.0.0 if [ "$1" = "up" ]; then Debug "ifconfig lo 127.0.0.1" ifconfig lo 127.0.0.1 Debug "route add -net 127.0.0.0" route add -net 127.0.0.0 fi } Menu_Config_Nethost() { Menu_Config_FQ_Name || return 1 Do_Ifcfg lo up Menu_Config_Netdev || return 1 Get_netprobe_Info Menu_Config_Router $1 Do_Ifcfg default up } # Ask_HOSTNAME ( {FQ,ETHER,ROUTER,NFS_SERVER,DNS_SERVER,MAIL_SERVER}, [default] ) # Ask_HOSTNAME() { while [ 1 ]; do # Ask_String --prehelp ":HELP_HOSTNAME:" $1_NAME $2 || return 1 Ask_String $1_NAME $2 || return 1 # Fixme Check_Hostname_Valid "$ANSWER" && return 0 return 0 done } # Ask_IP ( [--none] [--pretext PRETEXT ] [--help HELPTEXT] [--num NO] VARNAME [default] ) # Ask_IP() { local num= local help=":HELP_IP:" local pretext="" local var= local defval= local none_flag= local ipaddr= if [ $# -gt 0 -a "$1" = '--none' ]; then none_flag=true shift 1 fi if [ $# -gt 1 -a "$1" = "--pretext" ]; then pretext="$2" shift 2 fi if [ $# -gt 1 -a "$1" = "--help" ]; then help="$2" shift 2 fi if [ $# -gt 1 -a "$1" = "--num" ]; then num="$2" shift 2 fi if [ $# -gt 0 ]; then if [ $# -gt 1 ]; then defval="$2" fi if [ -z "$defval" ]; then defval="`Get_Val CONF_$1${num}_IP`" fi var="$1_IP" fi if [ -z "$var" ]; then var="IP" fi while [ 1 ]; do Ask_String --pretext "$pretext" --help "$help" $var $defval || return 1 if [ -z "$ANSWER" ]; then if [ -n "$none_flag" ]; then return 0 ; fi fi Check_IP_Addr_Valid "$ANSWER" || continue echo "new ANSWER = $ANSWER" >> /dev/tty4 return 0 done } Check_Host_Known() { local f_name=Check_Host_Known local f_args=1 # (hostname) -> "$FILE_ETC_HOSTS entry" Check_Args $f_name $f_args $# "$@" || return 255 sed -n "/ $1/p" $FILE_ETC_HOSTS } Check_IP_Addr_Known() { local f_name=Check_IP_Addr_Known local f_args=1 # (ipaddr) -> "$FILE_ETC_HOSTS entry" Check_Args $f_name $f_args $# "$@" || return 255 sed -n "/^$1 /p" $FILE_ETC_HOSTS } # Verify IP address and set ANSWER to an octal clean value and # set ANSWER2 to the corresponding netmask # Check_IP_Addr_Valid() { local f_name=Check_IP_Addr_Valid local f_args=1 # (ipaddr) -> ANSWER2 local field= local field1= local field2= local field3= local field4= local good= local octfree= export ANSWER2= Check_Args $f_name $f_args $# "$@" || return 255 # Test for invalid chars if [ -n "`Check_Chars_Valid "$1" "0123456789\."`" ]; then Error ":ERR_INVALID_IP_ADDR:" return 1 fi # Test for 3 dots if [ "`echo $1 | sed 's/[^\.]//g'`" != '...' ]; then Error ":ERR_INVALID_IP_ADDR:" return 1 fi IFS='.' read field1 field2 field3 field4 << EOF $1 EOF for field in $field1 $field2 $field3 $field4 ; do if [ $field -gt 255 -o 0 -gt $field ]; then Error ":ERR_INVALID_IP_ADDR:" return 1 fi # make sure IP address is octal clean to make do_netcalc happy good="$field" if [ $field -gt 0 ]; then # cut off heading zeros good="`echo $field | sed 's/^[0]*//'`" fi if [ -z "$octfree" ]; then octfree="${good}" else octfree="${octfree}.${good}" fi done # overwrite ANSWER (global) with octal free value echo "old ANSWER = $ANSWER" >> /dev/tty4 echo "octfree = $octfree" >> /dev/tty4 ANSWER="$octfree" ANSWER2="`do_netcalc -m $ANSWER`" return 0 } # Verify netmask for an IP addr and set ANSWER2 to corresponding broadcast # and ANSWER3 to corresponding net # Check_Netmask_Valid() { local f_name=Check_IP_Addr_Valid local f_args=2 # (netmask, ipaddr) -> ANSWER2, ANSWER3 local i local field export ANSWER2 export ANSWER3 Check_Args $f_name $f_args $# "$@" || return 255 Check_IP_Addr_Valid $2 || return 1 ANSWER2= ANSWER3= # Test for invalid chars if [ -n "`Check_Chars_Valid "$1" "0123456789\."`" ]; then Error ":ERR_INVALID_NETMASK:" return 1 fi # Test for 3 dots if [ "`echo $1 | sed 's/[^\.]//g'`" != '...' ]; then Error ":ERR_INVALID_NETMASK:" return 1 fi for i in 1 2 3 4 ; do field="`echo $1 | cut -d. -f $i`" if [ $field -gt 255 -o 0 -gt $field ]; then Error ":ERR_INVALID_NETMASK:" return 1 fi done ANSWER="$1" ANSWER2="`do_netcalc -b $2 $1`" ANSWER3="`do_netcalc -n $2 $1`" return 0 } Get_Net_Info() { # net info # FIXME: hardcoded strings echo echo -n "Hostname : " hostname echo echo -n "NIS domain : " domainname echo echo "Network interfaces :" cat /proc/net/dev echo echo "Active interfaces :" ifconfig -a echo echo "Routing table :" route -n if [ -f /usr/sbin/netstat ]; then echo echo "Network statistics :" netstat -i fi if [ -f /usr/sbin/rpcinfo ]; then echo echo "RPC informations :" rpcinfo -p fi if [ -f /usr/sbin/showmount ]; then echo echo "Exported filesystems :" showmount -e fi } Menu_Analyse_Net() { Show_Net_Info } Do_Setup_Mail() { local fqhn= local shortname= local domainname= fqhn="`Get_Val CONF_FQ_HOSTNAME $CONF_FQ_HOSTNAME`" shortname="`echo $CONF_FQ_HOSTNAME | cut -d'.' -f 1`" domainname="`echo $CONF_FQ_HOSTNAME | cut -d'.' -f 2-`" # # smail konfigurieren # if [ -f $FILE_SMAIL_CONFIG.sample ]; then sed "{ s/HOSTNAME/$shortname/g s/DOMAINNAME/$domainname/g }" $FILE_SMAIL_CONFIG.sample > $FILE_SMAIL_CONFIG chmod 644 $FILE_SMAIL_CONFIG if [ -f /usr/lib/smail/tools.linux/mkconfig ]; then # Msg ":INFO_PLEASE_CONFIGURE_SMAIL:" ( cd /usr/lib/smail ; tools.linux/mkconfig ) fi fi # # elm konfigurieren # if [ -f $FILE_ELM_RC.sample ]; then sed "{ s/DOMAINNAME/$domainname/g s/HOSTNAME/$shortname/g }" $FILE_ELM_RC.sample > $FILE_ELM_RC chmod 644 $FILE_ELM_RC fi } Do_Setup_FQ_Name() { local fqhn= local shortname= local domainname= fqhn="`Get_Val CONF_FQ_HOSTNAME`" shortname="`echo $fqhn | cut -d'.' -f 1`" domainname="`echo $fqhn | cut -d'.' -f 2-`" if [ -n "$shortname" ]; then hostname $shortname Do_Store CONF_NODENAME "$shortname" Do_Store CONF_DNS_DOMAIN "$domainname" Do_Store CONF_DNS_SEARCH "$domainname" mkdir -p $DIR_TARGET/etc/sysconfig touch $DIR_TARGET/etc/sysconfig/network set_val -f $DIR_TARGET/etc/sysconfig/network HOSTNAME $fqhn fi Set_etc_HOSTNAME Do_Setup_DNS } Menu_Config_FQ_Name() { local fqhn= local shortname= local domainname= local eth0name= fqhn="`Get_Val CONF_FQ_HOSTNAME`" Ask_HOSTNAME FQ $fqhn || return 1 if [ -z "$ANSWER" ]; then return 1 ; fi fqhn="$ANSWER" Do_Store CONF_FQ_HOSTNAME "$fqhn" Do_Setup_FQ_Name eth0name="`Get_Val CONF_eth0_NAME`" if [ -n "$eth0name" ]; then Do_Store CONF_eth0_NAME "$fqhn" fi Do_Setup_Hosts return 0 } Menu_Config_Net_Connect() { local item # "Menu_Config_UUCP" ":MENU_CONFIG_UUCP:" while [ 1 ]; do if [ -z "$item" ]; then item="Menu_Config_Ether" ; fi $CMD_BOX --help ":MENU_CONFIG_NET_CONNECT_HELP:" \ --default "$item" \ --title ":MENU_CONFIG_NET_CONNECT_TITLE:" \ --menu ":MENU_CONFIG_NET_CONNECT_TEXT:" \ "Menu_Config_Ether" ":MENU_CONFIG_ETHER:" \ "Menu_Config_Router" ":MENU_CONFIG_ROUTER:" 2> $FILE_TMP_ANSWER || break COMMAND="`cat $FILE_TMP_ANSWER`" if [ -n "$COMMAND" ]; then $COMMAND fi done } Do_Setup_DNS() { local fqhn="`Get_Val CONF_FQ_HOSTNAME`" local domainname="`echo $fqhn | cut -d'.' -f 2-`" local domain="`Get_Val CONF_DNS_DOMAIN`" local search="`Get_Val CONF_DNS_SEARCH`" local server1="`Get_Val CONF_DNS_SERVER1_IP`" local server2="`Get_Val CONF_DNS_SERVER2_IP`" local server3="`Get_Val CONF_DNS_SERVER3_IP`" local DomainLine= local SearchLine= local Server1Line= local Server2Line= local Server3Line= if [ -n "$domain" ]; then DomainLine="domain $domain" else if [ -n "$domainname" ]; then domain="$domainname" Do_Store CONF_DNS_DOMAIN "$domain" DomainLine="domain $domain" fi fi if [ -n "$search" ]; then SearchLine="search $search" else if [ -n "$domain" ]; then search="$domain" Do_Store CONF_DNS_SEARCH "$search" SearchLine="search $search" fi fi if [ -n "$server1" ]; then Server1Line="nameserver $server1" fi if [ -n "$server2" ]; then Server2Line="nameserver $server2" fi if [ -n "$server3" ]; then Server3Line="nameserver $server3" fi # we don't prefix it with $DIR_TARGET as we copy it later cat << EOF > $FILE_ETC_RESOLV_CONF # $FILE_ETC_RESOLV_CONF - DNS setup file # # possible entries are: # # domain <domain> Local domain name. If not present, the # gethostbyname syscall is used to # determine the local domain name. # # search <list_of_domains> Search list for hostname lookup. # The search list is normally determined # from the local domain name but it # can be set to a list of domains. # # nameserver <ip_addr> Define which server to contact # for DNS lookups. If there are # multiple nameserver lines (Max=3), # they are queried in the listed order. # # !!! Automatically generated by LISA from /etc/system.cnf. Do not edit !!! # $DomainLine $SearchLine $Server1Line $Server2Line $Server3Line EOF chmod 644 $FILE_ETC_RESOLV_CONF } Menu_Config_DNS() { local server1="`Get_Val CONF_DNS_SERVER1_IP`" local server2="`Get_Val CONF_DNS_SERVER2_IP`" local server3="`Get_Val CONF_DNS_SERVER3_IP`" local dnssetup=NONE local num local retry local none_flag while [ 1 ]; do retry= none_flag= Ask_Bool DNS_SERVER || return 1 if [ "$ANSWER" = "0" ]; then dnssetup=CLIENT else dnssetup=SERVER fi case $dnssetup in SERVER) # Ask_Bool DNS_SERVER_LOCAL n || return 1 ANSWER=1 case $ANSWER in 0) # setup localhost as nameserver server1="127.0.0.1" server2= server3= Err_Not_Implemented ;; 1) # then we just use $FILE_ETC_HOSTS server1= server2= server3= ;; esac ;; CLIENT) # We are a DNS client. Ask for IP addr of DNS servers. for num in 1 2 3 ; do if [ $num -gt 1 ]; then none_flag='--none' ; fi none_flag='--none' Ask_IP $none_flag --pretext "DNS server $num ; " --help ":HELP_IP:" --num $num DNS_SERVER if [ $? -ne 0 ]; then retry=true ; break ; fi if [ -z "$ANSWER" ]; then break ; fi eval "`echo \"server$num=$ANSWER\"`" done ;; esac if [ -n "$retry" ]; then continue ; fi break done Do_Store CONF_DNS_SERVER1_IP "$server1" Do_Store CONF_DNS_SERVER2_IP "$server2" Do_Store CONF_DNS_SERVER3_IP "$server3" Do_Setup_DNS } Menu_Config_Netdev() { export ANSWER= local supported_netdevs="eth0 eth1 tr0 plip0 plip1 plip2" local dev= local ip= local remote_ip= local mask= local bcast= local net= local name= local trydev= # FIXME: supports all network devices, not only a limited list for trydev in $supported_netdevs ; do if [ -n "`fgrep $trydev /proc/net/dev`" ]; then dev="$trydev" break fi done # FIXME: A list of available devices should be created dynamically Ask_String ETHER_DEV $dev || return 1 dev="$ANSWER" if [ -z "`fgrep $dev /proc/net/dev`" ]; then Error "$dev ; :ERR_NO_DEVICE_AND_NO_MODULE:" # FIXME: this should fall back to module loading... return 1 fi case $dev in lo|eth0|eth1|plip0|plip1|plip2|tr0) ;; *) Err_Not_Implemented return 1 ;; esac while [ 1 ]; do # interface device Do_Store CONF_${dev}_DEV "$dev" # interface ip ip="`Get_Val CONF_${dev}_IP`" if [ -z "$ip" ]; then ip=192.168.0.1 fi Ask_IP ETHER $ip || continue ip="$ANSWER" Do_Store CONF_${dev}_IP "$ip" if [ "$dev" = "plip0" -o "$dev" = "plip1" ]; then # remote (pointopoint) ip remote_ip="`Get_Val CONF_${dev}_REMOTE_IP`" if [ -z "$remote_ip" ]; then remote_ip=192.168.0.2 fi Ask_IP ETHER_REMOTE $remote_ip || continue remote_ip="$ANSWER" Do_Store CONF_${dev}_REMOTE_IP "$remote_ip" else # interface netmask, broadcast and netroute if [ -z "$ANSWER2" ]; then ANSWER2="255.255.255.0" fi mask="`Get_Val CONF_${dev}_MASK`" if [ -z "$mask" ]; then mask="$ANSWER2" fi Ask_String NETMASK $mask || continue mask="$ANSWER" Check_Netmask_Valid "$mask" $ip || continue bcast="$ANSWER2" net="$ANSWER3" Ask_String BROADCAST $bcast || continue bcast="$ANSWER" Do_Store CONF_${dev}_MASK "$mask" Do_Store CONF_${dev}_BCAST "$bcast" Do_Store CONF_${dev}_NET "$net" fi break done # assumption: interface name = hostname name="`Get_Val CONF_FQ_HOSTNAME`" Do_Store CONF_${dev}_NAME "$name" Do_Setup_Hosts Set_network Do_Ifcfg $dev up > $FILE_TMP_ERR 2>&1 Do_Store CONF_${dev}_STAT up Set_ifcfg ${dev} ANSWER="${dev}" return 0 } Menu_Config_Ether() { export ANSWER= local first_install= local shortname= local fqhn= local dev=eth0 local ip= local pointopoint= local mask= local bcast= local net= local name= if [ $# -gt 0 -a "$1" = "first" ]; then first_install=true shift 1 fi if [ $# -gt 0 -a "$1" = "eth1" ]; then dev=eth1 shift 1 fi while [ 1 ]; do if [ -n "$first_install" ]; then Do_Store CONF_${dev}_STAT up else Ask_Bool ETHER || return 1 case $ANSWER in 0) Do_Store CONF_${dev}_STAT up prep_use NETCONF ;; 1) Do_Store CONF_${dev}_STAT down return 0 ;; esac fi # interface device Debug "Calling Get_Val" dev="`Get_Val CONF_${dev}_DEV`" if [ -z "$dev" ]; then dev="eth0" fi Ask_String ETHER_DEV $dev || return 1 dev="$ANSWER" if [ -z "`fgrep $dev /proc/net/dev`" ]; then Error "$dev ; :ERR_NO_DEVICE_AND_NO_MODULE:" # FIXME: this should fall back to module loading... return 1 fi Do_Store CONF_${dev}_DEV "$dev" # interface ip ip="`Get_Val CONF_${dev}_IP`" Ask_IP ETHER $ip || continue ip="$ANSWER" Do_Store CONF_${dev}_IP "$ip" # interface netmask, broadcast and netroute if [ -z "$ANSWER2" ]; then ANSWER2="255.255.255.0" fi mask="`Get_Val CONF_${dev}_MASK`" if [ -z "$mask" ]; then mask="$ANSWER2" fi Ask_String NETMASK $mask || continue Check_Netmask_Valid "$ANSWER" $ip || continue mask="$ANSWER" bcast="$ANSWER2" net="$ANSWER3" Ask_String BROADCAST $bcast || continue bcast="$ANSWER" Do_Store CONF_${dev}_MASK "$mask" Do_Store CONF_${dev}_BCAST "$bcast" Do_Store CONF_${dev}_NET "$net" break done # assumption: interface name = hostname fqhn="`Get_Val CONF_FQ_HOSTNAME`" name="$fqhn" Do_Store CONF_${dev}_NAME "$name" Do_Setup_Hosts Set_network Do_Ifcfg $dev up > $FILE_TMP_ERR 2>&1 Set_ifcfg ${dev} return 0 } Do_Setup_Hosts() { local fqhn="`Get_Val CONF_FQ_HOSTNAME`" local nodename="`echo $fqhn | cut -d'.' -f 1`" local eth0name="`Get_Val CONF_eth0_NAME`" local eth1name="`Get_Val CONF_eth1_NAME`" local tr0name="`Get_Val CONF_tr0_NAME`" local LocalhostLine= local eth0Line= local eth1Line= local tr0Line= local shortname= if [ -n "$eth0name" ]; then shortname="`echo $eth0name | cut -d'.' -f 1`" eth0Line="`Get_Val CONF_eth0_IP` $eth0name $shortname" fi if [ -n "$eth1name" ]; then shortname="`echo $eth1name | cut -d'.' -f 1`" eth1Line="`Get_Val CONF_eth1_IP` $eth1name $shortname" fi if [ -n "$tr0name" ]; then shortname="`echo $tr0name | cut -d'.' -f 1`" tr0Line="`Get_Val CONF_tr0_IP` $tr0name $shortname" fi if [ "$fqhn" != "$nodename" ]; then shortname="$nodename" fi if [ -z "${eth0name}${eth1name}${tr0name}" ]; then LocalhostLine="127.0.0.1 $fqhn $shortname localhost" else LocalhostLine="127.0.0.1 localhost" fi # we don't prefix it with $DIR_TARGET as we copy it later Do_Backup_File $FILE_ETC_HOSTS cat << EOF > $FILE_ETC_HOSTS # $FILE_ETC_HOSTS - hostname_to_address mappings for the resolver library # # The format is: # # ipaddr fully_qualified_hostname list_of_nicknames # # We strongly recommend to use a fully qualified hostname for your machine # if it is connected to any type of network. You can add short nicknames as # you like, but the official canonical name is the name that follows the # IP address and should always be a fully qualified hostname. # # If you don't have any network interfaces, you should put your hostname # in the line of your loopback device, which has the address 127.0.0.1. # # LISA will automatically put the hostname in the right line for you. # # # !!! Automatically generated by LISA from /etc/system.cnf. Do not edit !!! # # The loopback device. It should always be available. # $LocalhostLine # # Your first IP interface (if you are connected to any kind of network) # $eth0Line $tr0Line # # Your second IP interface (normally for routers only) # $eth1Line # # If you have a nameserver we recommend to use it instead of putting many # hosts in this file. If you don't have a nameserver though, you can add # hostnames and their IP addresses below this line. # #=========================================================================== EOF chmod 644 $FILE_ETC_HOSTS if [ -f ${FILE_ETC_HOSTS}~ ]; then sed -n '/^#====/,${ /^#====/d p }' ${FILE_ETC_HOSTS}~ >> $FILE_ETC_HOSTS fi } List_HOSTS() { cat $FILE_ETC_HOSTS | sed '{ /^#/d /^$/d }' } Build_HOSTS() { List_HOSTS | do_quote } Menu_Hosts_Show() { List_HOSTS > $FILE_TMP_MSG Browse2 $FILE_TMP_MSG HOSTS || return 1 } Menu_Hosts_Add() { local ipaddr= local fqhn= local nickname= while [ 1 ]; do Ask_IP HOST_ADD "$ipaddr" || return 1 ipaddr="$ANSWER" sed -n "/^$ipaddr /p" $FILE_ETC_HOSTS > $FILE_TMP_ERR if [ -s $FILE_TMP_ERR ]; then Error --file $FILE_TMP_ERR ":ERR_IP_CONFLICT:" continue fi Ask_String HOST_ADD || continue fqhn="$ANSWER" sed -n "/ $fqhn$/p" $FILE_ETC_HOSTS > $FILE_TMP_ERR sed -n "/ $fqhn /p" $FILE_ETC_HOSTS >> $FILE_TMP_ERR if [ -s $FILE_TMP_ERR ]; then Error --file $FILE_TMP_ERR ":ERR_HOSTNAME_CONFLICT:" continue fi $CMD_BOX --title ":ASK_HOST_ADD_TITLE:" --string ":ASK_HOST_ADD_NICKNAME:" 2> $FILE_TMP_ANSWER || continue nickname="`cat $FILE_TMP_ANSWER`" sed -n "/ $nickname$/p" $FILE_ETC_HOSTS > $FILE_TMP_ERR sed -n "/ $nickname /p" $FILE_ETC_HOSTS >> $FILE_TMP_ERR if [ -s $FILE_TMP_ERR ]; then Error --file $FILE_TMP_ERR ":ERR_NICKNAME_CONFLICT:" continue fi echo "$ipaddr $fqhn $nickname" >> $FILE_ETC_HOSTS return 0 done } Menu_Hosts_Del() { Choose --menutitle ":INFO_HOSTS_MENUTITLE:" --build Build_HOSTS HOST_DEL || return 1 if [ -z "$ANSWER" ]; then Error "no host specified" return 1 fi if [ "$ANSWER" = "127.0.0.1" ]; then Warn ":WARN_KEEP_LOCALHOST:" return 0 fi if [ "$ANSWER" = "`Get_Val CONF_eth0_IP`" ]; then Warn ":WARN_KEEP_YOUR_IP:" return 0 fi sed "/^$ANSWER/d" $FILE_ETC_HOSTS > $FILE_ETC_HOSTS.tmp mv $FILE_ETC_HOSTS.tmp $FILE_ETC_HOSTS return 0 } Menu_Config_Hosts() { local=item while [ 1 ]; do if [ -z "$item" ]; then item="Menu_Hosts_Show" ; fi $CMD_BOX --help ":MENU_CONFIG_HOSTS_HELP:" \ --default "$item" \ --title ":MENU_CONFIG_HOSTS_TITLE:" \ --menu ":MENU_CONFIG_HOSTS_TEXT:" \ "Menu_Hosts_Show" ":MENU_HOSTS_SHOW:" \ "Menu_Hosts_Add" ":MENU_HOSTS_ADD:" \ "Menu_Hosts_Del" ":MENU_HOSTS_DEL:" 2> $FILE_TMP_ANSWER || break COMMAND="`cat $FILE_TMP_ANSWER`" item="$COMMAND" $COMMAND done return 0 } Do_Setup_NIS_glibc() { local domain="`Get_Val CONF_NIS_DOMAIN`" local server1="`Get_Val CONF_NIS_SERVER1_IP`" local server2="`Get_Val CONF_NIS_SERVER2_IP`" local server3="`Get_Val CONF_NIS_SERVER3_IP`" local DomainLine= local Server1Line= local Server2Line= local Server3Line= if [ -n "$domain" ]; then DomainLine="domain $domain" domainname $domain fi if [ -n "$server1" ]; then Server1Line="$DomainLine server $server1" else Server1Line="$DomainLine broadcast" fi if [ -n "$server2" ]; then Server2Line="ypserver $server2" fi if [ -n "$server3" ]; then Server3Line="ypserver $server3" fi cat << EOF > $DIR_TARGET$FILE_NIS_CONF # $FILE_NIS_CONF - NIS setup file # # possible entries are: # # domain <domain> broadcast This is the default NIS domain; # Broadcasts are used to find an # eligible server (insecure). # alternatively # # domain <domain> server <ip> Additionally specify which host # to contact for NIS service. # # ypserver <ip> Fall-Back servers for NIS can # be added this way for the case # that the primary server is down. # # !!! This file may be automatically regenerated by LISA from # /etc/system.cnf. Edit at your own risk !!! # $Server1Line $Server2Line $Server3Line EOF chmod 644 $DIR_TARGET$FILE_NIS_CONF # filter out NIS lines from passwd and group sed '/^\+/d' $DIR_TARGET$FILE_ETC_PASSWD > $DIR_TARGET$FILE_ETC_PASSWD.tmp sed '/^\+/d' $DIR_TARGET$FILE_ETC_GROUP > $DIR_TARGET$FILE_ETC_GROUP.tmp if [ -n "$domain" ]; then # add NIS lines to passwd and group if NIS domain set echo "+::::::" >> $DIR_TARGET$FILE_ETC_PASSWD.tmp echo "+:::" >> $DIR_TARGET$FILE_ETC_GROUP.tmp fi chmod 644 $DIR_TARGET$FILE_ETC_PASSWD.tmp chmod 644 $DIR_TARGET$FILE_ETC_GROUP.tmp mv $DIR_TARGET$FILE_ETC_PASSWD.tmp $DIR_TARGET$FILE_ETC_PASSWD mv $DIR_TARGET$FILE_ETC_GROUP.tmp $DIR_TARGET$FILE_ETC_GROUP } Menu_Config_NIS() { local dir_daemons=$DIR_TARGET/etc/sysconfig/daemons local num local retry local none_flag local nisdomain="`Get_Val CONF_NIS_DOMAIN`" local server1="`Get_Val CONF_NIS_SERVER1_IP`" local server2="`Get_Val CONF_NIS_SERVER2_IP`" local server3="`Get_Val CONF_NIS_SERVER3_IP`" local ip= local nissetup # try to find a good default value if [ -n "$nisdomain" ]; then # We do not really configure a NIS server, so default to CLIENT #if [ -n "$server1$server2$server3" ]; then nissetup=CLIENT #else # nissetup=SERVER #fi else nissetup=NONE fi while [ 1 ]; do retry= none_flag= Choose --none NIS $nissetup || return 1 nissetup="$ANSWER" if [ -z "$nissetup" ]; then nisdomain= server1= server2= server3= # disable nis server autostart Do_Setup_Daemon nis-server no break fi Ask_String NIS_DOMAIN $nisdomain || continue nisdomain="$ANSWER" case $nissetup in SERVER) # we are NIS server and client. server1=127.0.0.1 # enable nis server autostart Do_Setup_Daemon nis-server yes ;; CLIENT) # We are a NIS client. Ask for IP addr of NIS servers. for num in 1 2 3 ; do if [ $num -gt 1 ]; then none_flag='--none' ; fi none_flag='--none' Ask_IP $none_flag --pretext "NIS server $num ; " --help ":HELP_NIS_SERVER: :HELP_IP:" --num $num NIS_SERVER if [ $? -ne 0 ]; then retry=true ; break ; fi if [ -z "$ANSWER" ]; then break ; fi eval "`echo \"server$num=$ANSWER\"`" done # disable nis server autostart Do_Setup_Daemon nis-server no if [ -f $dir_daemons/nis-client ]; then Do_Setup_Daemon nis-client yes fi ;; esac if [ -n "$retry" ]; then continue ; fi break done Do_Store CONF_NIS_DOMAIN "$nisdomain" Do_Store CONF_NIS_SERVER1_IP "$server1" Do_Store CONF_NIS_SERVER2_IP "$server2" Do_Store CONF_NIS_SERVER3_IP "$server3" Do_Setup_NIS_glibc return 0 } Menu_Config_Router() { local first_install= local defval= local v=CONF_ROUTER1_IP local r_ip="`Get_Val $v`" local my_net="`Get_Val CONF_eth0_NET`" local prefix= local suffix= if [ $# -gt 0 -a "$1" = "first" ]; then first_install=true shift 1 fi if [ -n "$r_ip" -o -n "$first_install" ]; then defval=j else defval=n fi Ask_Bool ROUTER $defval if [ "$ANSWER" = "1" ]; then Do_Store $v "" return 0 fi if [ -z "$r_ip" ]; then # try to make a good suggestion for the Router IP if [ -n "$my_net" ]; then prefix="`echo $my_net | cut -d'.' -f 1-3`" suffix="`echo $my_net | cut -d'.' -f 4`" suffix="`do_calc $suffix + 1`" r_ip="${prefix}.${suffix}" fi fi Ask_IP ROUTER $r_ip || return 1 r_ip="$ANSWER" Do_Store $v "$r_ip" Set_ifcfg eth0 if [ -n "$r_ip" ]; then Do_Ifcfg default up fi return 0 } Ask_HOST() { local num= if [ $# -gt 1 -a "$1" = "--num" ]; then num="--num $2" shift 2 fi Ask_IP $num $1 || return 1 return 0 } Get_Supported_MTAs() { # FIXME: this should be global and defined in /etc/lst.cnf local supported="sendmail smail qmail" echo $supported } Check_MTA_Available() { if [ -f $DIR_TARGET/etc/mta/options/$1 ]; then return 0 else return 1 fi } Build_MTA() { local i for i in `Get_Supported_MTAs` ; do Check_MTA_Available $i || continue echo "\"$i\" \"Mail Transfer Agent ($i)\" \\" done } Do_Setup_MTA() { local mta_new="$1" local mta_old= local mta_switch_cmd=$DIR_TARGET/usr/sbin/mta-switch local suffix= if [ "$DIR_TARGET" != "/" ]; then suffix='-norun' fi if [ ! -f $mta_switch_cmd ]; then echo "$mta_switch_cmd : file not found" > $FILE_TMP_ERR return 1 fi mta_old="`$mta_switch_cmd query`" # turn off any MTA we had before if [ -n "$mta_old" -a "$mta_old" != "none" ]; then $mta_switch_cmd off${suffix} 2> $FILE_TMP_ERR || return 1 fi # turn on new MTA $mta_switch_cmd --${mta_new} on${suffix} 2> $FILE_TMP_ERR || return 1 rm -f $FILE_TMP_ERR return 0 } Choose_MTA() { local last_mta while [ 1 ]; do if [ -f /etc/sysconfig/daemons/mta ]; then last_mta="`get_val -f /etc/sysconfig/daemons/mta VARIANT`" fi Choose --build Build_MTA MTA $last_mta || return 1 Do_Setup_MTA $ANSWER && break Error --file $FILE_TMP_ERR done return 0 } Menu_Config_Net_Services() { local i local mta_cmd="Choose_MTA" local mta_label=":CHOOSE_MTA:" local mta_active=false # we like dynamic menues ;-) for i in `Get_Supported_MTAs` ; do Check_MTA_Available $i || continue mta_active=true done if [ "$mta_active" = "false" ]; then mta_cmd= mta_label= fi # those should be handled similar # "Menu_Config_Mail" ":MENU_CONFIG_MAIL:" # "Menu_Config_News" ":MENU_CONFIG_NEWS:" while [ 1 ]; do $CMD_BOX --help ":MENU_CONFIG_NET_SERVICES_HELP:" \ --title ":MENU_CONFIG_NET_SERVICES_TITLE:" \ --menu ":MENU_CONFIG_NET_SERVICES_TEXT:" \ "Menu_Config_DNS" ":MENU_CONFIG_DNS:" \ "Menu_Config_NIS" ":MENU_CONFIG_NIS:" \ $mta_cmd $mta_label 2> $FILE_TMP_ANSWER || break case $? in 0) COMMAND="`cat $FILE_TMP_ANSWER`" $COMMAND ;; 1) break ;; esac done } Menu_Config_Net() { local=item while [ 1 ]; do if [ -z "$item" ]; then item="Menu_Config_Net_Services" ; fi $CMD_BOX --help ":MENU_CONFIG_NET_HELP:" \ --default "$item" \ --title ":MENU_CONFIG_NET_TITLE:" \ --menu ":MENU_CONFIG_NET_TEXT:" \ "Menu_Config_Hosts" ":MENU_CONFIG_HOSTS:" \ "Menu_Config_Net_Connect" ":MENU_CONFIG_NET_CONNECT:" \ "Menu_Config_Net_Services" ":MENU_CONFIG_NET_SERVICES:" 2> $FILE_TMP_ANSWER || break COMMAND="`cat $FILE_TMP_ANSWER`" item="$COMMAND" $COMMAND done return 0 } Prepare_SMB_Install() { Info "Switching to SMB install mode (BETA)" sleep 5 MountModulesFloppy || return 1 while [ 1 ]; do Do_Load_Module_mini --silent smbfs "" || break if [ ! -f /floppy/usr/bin/smbmount.gz ]; then break ; fi cp -a /floppy/usr/bin/smbmount.gz /usr/bin || break gunzip /usr/bin/smbmount.gz || break return 0 done umount /floppy Msg "Problems with smbfs or smbmount. SMB install not possible." return 1 } Menu_Mount_NFS() { local nfsserver="$1" local mountdir="$2" local nfspath="$3" local smbuser="Administrator" local netbiosname="" export ANSWER= while [ 1 ]; do Ask_String INSTALL_PATH_SRC $nfspath || return 1 nfspath="$ANSWER" if [ -z "$mountdir" ]; then Ask_String MOUNT_TARGET_DIR || continue fi if [ "`echo $nfspath | cut -c1,2`" = '//' ]; then # Dirty hack to support SMB installs Prepare_SMB_Install netbiosname="`echo $nfspath | cut -d'/' -f 3`" $CMD_BOX --string "SMB login name" --default "$smbuser" 2> $FILE_TMP_ANSWER || continue smbuser="`cat $FILE_TMP_ANSWER`" echo "$nfsserver $netbiosname" >> /etc/hosts if [ -n "$smbuser" ]; then reset 2>&1 Do_Clear_Screen echo "smbmount $nfspath /mnt -I $nfsserver -U $smbuser" smbmount $nfspath /mnt -I $nfsserver -U $smbuser 2>&1 if [ $? -eq 0 ]; then break ; fi else smbmount $nfspath /mnt -I $nfsserver -n && break fi echo -n "smbmount failed. press <return> to continue." read ans # cleanup /etc/hosts if the mount failed sed "/^${nfsserver} ${netbiosname}$/d" /etc/hosts > /etc/hosts.tmp mv /etc/hosts.tmp /etc/hosts else Do_Mount -o ro "${nfsserver}:${nfspath}" $mountdir && break fi done export ANSWER="${nfspath}" return 0 } Show_Net_Info() { Get_Net_Info > $FILE_TMP_MSG Browse2 $FILE_TMP_MSG ANALYSE || return 1 return 0 } # libLSTpkg - package handling library shared between several scripts # # Copyright (C) 1993-1997 Ralf Flaxa, LST Software GmbH, Erlangen, Germany # Build_SERIES() { Do_Calc_Freespace $DIR_TARGET touch $FILE_PKGS_SEL build_menu -U $FREESPACE -f -t $FILE_PKGS_SEL -d $FILE_PKGS_DATA } Get_Dependend_Pkgs() { local preset=$1 Debug "add dependend pkgs for $preset" # add pcmcia where necessary case $preset in min|minx|small) if [ -n "`sed -n '/^pcmcia_core/p' /proc/modules`" ]; then echo "pcmcia-cs" fi ;; esac } Get_Preset_Pkgs() { local preset=$1 local preset_file=/floppy/usr/lib/LST/pkgs.$preset.gz local series Debug "generate preset pkgs for $preset" if [ "$CND10_MODE" = "true" ]; then # use fixed preset file if [ -r $preset_file ]; then gzip -dfcv < $preset_file | sed '/^#/d' else Debug "preset file $preset not found. Use all." build_menu -n -p ":1:" -d $FILE_PKGS_DATA fi else case $preset in all|fileprintserver|minimum|minimumserver|networkserver|recommended|webserver) preset_file=/mnt/install/col/data/pkgs-0*${preset}.generic if [ -f $preset_file ]; then # FIXME: ugly hack to filter out version numbers (XFree86) sed 's/-[0123456789.]*$//' $preset_file > /tmp/mypkgs build_menu -t /tmp/mypkgs -n -p ":1:" -d $FILE_PKGS_DATA elif [ "$preset" = "all" ]; then build_menu -n -p ":1:" -d $FILE_PKGS_DATA else return 1 fi ;; min) # only default packages of series basis and network for series in basis network ; do build_menu -n -c 1 -s $series -m ":2:j:" -p ":1:" -d $FILE_PKGS_DATA done ;; minx) # only default packages of series basis, network, xbasis and xappl for series in basis network xbasis xappl ; do build_menu -n -c 1 -s $series -m ":2:j:" -p ":1:" -d $FILE_PKGS_DATA done ;; small) # only default of all series for series in basis develop doku network tex text xappl xbasis xdevelo xemacs xextra xview ; do build_menu -n -c 1 -s $series -m ":2:j:" -p ":1:" -d $FILE_PKGS_DATA done ;; rec) # all pkgs of series basis for series in basis ; do build_menu -n -s $series -p ":1:" -d $FILE_PKGS_DATA done # all pkgs of series xbasis but no X servers sed '/^XSERV:/d' $FILE_PKGS_DATA | build_menu -n -s xbasis -p ":1:" # rec pkgs of series text,doku,develop,misc,network,tex,xappl,xemacs,xview for series in develop doku misc network text tex xappl xemacs xview ; do build_menu -n -c 2 -s $series -m ":2:j:" -p ":1:" -d $FILE_PKGS_DATA done ;; sel) # expert's private choice ;-) build_menu -t /usr/lib/LST/pkgs.sel -n -p ":1:" -d $FILE_PKGS_DATA ;; esac Get_Dependend_Pkgs $preset fi } Get_Preset_Size() { local preset=$1 # we have an overhead of about 20% for inodes, administrative data etc. # current algorithm is (x MB + 2 MB) * 1.20 local fudge_factor=20 local approx_usage= local preset_file=/floppy/usr/lib/LST/pkgs.$preset.gz if [ "$CND10_MODE" = "true" ]; then if [ -r $preset_file ]; then # grep precalculated from preset file gzip -dfcv < $preset_file | sed -n 's/^#% NEEDSPACE: ([0-9][0-9]*) MB.*/\1/p' else echo "?" fi else # generate selection list depending on the preset type Get_Preset_Pkgs $preset > $FILE_PKGS_SEL Do_Calc_Needspace $FILE_PKGS_SEL approx_usage="`do_calc $NEEDSPACE \* $fudge_factor`" approx_usage="`do_calc $approx_usage / 100`" approx_usage="`do_calc $approx_usage \+ $NEEDSPACE`" do_calc $approx_usage / 1048576 fi } Build_PKG_SELECT_PRESET() { local preset="$1" local size="$2" local preset_file case $preset in sel) if [ ! -f /usr/lib/LST/pkgs.sel ]; then return 0 fi ;; all|fileprintserver|minimum|minimumserver|networkserver|recommended|webserver) preset_file=/mnt/install/col/data/pkgs-0*${preset}.generic if [ ! -f $preset_file ]; then return 0 fi ;; esac echo "\"Menu_Pkg_Select_Preset $preset\" \":MENU_PKG_SELECT_PRESET_${preset}: (min. $size MB)\" \\" } Build_PKG_SELECT() { local size_spare="`do_calc $SPARESPACE / 1048576`" local size_data= local size= #local profiles="sel minimumserver webserver fileprintserver networkserver recommended rec minimum min minx small all" local profiles="sel minimumserver webserver fileprintserver networkserver recommended minimum all" local preset if [ "$DIR_TARGET" != "/" ]; then for preset in $profiles ; do size_data="`Get_Preset_Size $preset`" size="`do_calc $size_data + $size_spare`" Build_PKG_SELECT_PRESET $preset $size done fi # offer customizable selection in expert mode Is_Expert if [ $? -eq 0 ]; then cat << EOF "Menu_Pkg_Select_Services" ":MENU_PKG_SELECT_SERVICES:" \\ "Menu_Pkg_Select_Series" ":MENU_PKG_SELECT_SERIES:" \\ "Menu_Pkg_Select_Pkgs" ":MENU_PKG_SELECT_PKGS:" \\ EOF fi } Build_SELECT_PRIO() { local statistics= local dummy= local pkgnum= local summin= local sumrec= local sumall= local sumsel= # Get statistics touch $FILE_PKGS_SEL touch $DIR_LST_TMP/$1.sel statistics="`build_menu -S -s $1 -T $DIR_LST_TMP/$1.sel -d $FILE_PKGS_DATA`" Debug "statistics for SERIES <$1> is <$statistics>" if [ -z "$statistics" ]; then cat << EOF "1" ":TYPE_SEL_MIN:" \\ "2" ":TYPE_SEL_REC:" \\ "3" ":TYPE_SEL_ALL:" \\ "0" ":TYPE_SEL_NOT:" \\ EOF else IFS=':' read dummy dummy pkgnum summin sumrec sumall sumsel dummy << EOF $statistics EOF cat << EOF --menutitle ":CHOOSE_SELECT_PRIO_MENUTITLE: $1 ($pkgnum :PKGS:)" \\ EOF if [ -s $DIR_LST_TMP/$SERIES.sel -a "$sumsel" != "0" ]; then echo "\"4\" \":TYPE_SEL_LAST:\" \\" fi cat << EOF "1" ":TYPE_SEL_MIN: ($summin kB)" \\ "2" ":TYPE_SEL_REC: ($sumrec kB)" \\ "3" ":TYPE_SEL_ALL: ($sumall kB)" \\ EOF echo "\"0\" \":TYPE_SEL_NOT:\" \\" fi } Build_INSTALL_MEDIUM() { # "tape" ":TYPE_INSTALL_MEDIUM_TAPE:" # "slip" ":TYPE_INSTALL_MEDIUM_SLIP:" if [ "$DIR_TARGET" = "/" ]; then cat << EOF "path" ":TYPE_INSTALL_MEDIUM_PATH:" \\ EOF fi cat << EOF "cdrom" ":TYPE_INSTALL_MEDIUM_CDROM:" \\ "harddisk" ":TYPE_INSTALL_MEDIUM_HARDDISK:" \\ "network" ":TYPE_INSTALL_MEDIUM_NETWORK:" \\ EOF } Build_PKG() { touch /tmp/LST/HOPE cat /tmp/LST/HOPE rm -f /tmp/LST/HOPE } Build_PKG_Info() { build_menu -f -d $FILE_PKGS_DATA } Build_PKG_Installed() { build_menu -f -d $FILE_PKGS_DATA } Check_Pkg_Database() { if [ -z "$FILE_PKGS_DATA" ]; then Msg ":ERR_MISSING_PKG_DATABASE_FILE_NAME:" return 1 fi if [ ! -f "$FILE_PKGS_DATA" ]; then Msg ":ERR_MISSING_PKG_DATABASE:" return 1 fi return 0 } Check_Pkg_Index() { if [ -z "$FILE_PKGS_INDEX" ]; then Msg ":ERR_MISSING_PKG_INDEX_FILE_NAME:" return 1 fi if [ ! -f "$FILE_PKGS_INDEX" ]; then Msg ":ERR_MISSING_PKG_INDEX:" return 1 fi return 0 } Choose_Install_Source() { # If we run from the lisa live filesystem we use a simpler routine if [ -n "`sed -n '/^er=/p' /tmp/cmdline | fgrep text`" ]; then while [ 1 ]; do rm -f /source if [ -n "`mount | fgrep /mnt/install | fgrep ':'`" ]; then ANSWER="network" else ANSWER="cdrom" fi CONF_INSTALL_MEDIUM="$ANSWER" Debug "CONF_INSTALL_MEDIUM=<$CONF_INSTALL_MEDIUM>" Do_Store CONF_INSTALL_MEDIUM "$CONF_INSTALL_MEDIUM" case $CONF_INSTALL_MEDIUM in network) CONF_INSTALL_DEV="`mount | fgrep ' on /mnt/install ' | cut -d':' -f 1`" Is_Known_Source /mnt/install || continue ;; cdrom) CONF_INSTALL_DEV="`mount | fgrep ' on /mnt/install ' | cut -d' ' -f 1`" ln -sf $CONF_INSTALL_DEV /dev/cdrom Is_Known_Source /mnt/install || continue ;; esac ln -sf $DIR_SOURCE /source break done Do_Store CONF_INSTALL_DEV "$CONF_INSTALL_DEV" Do_Store CONF_INSTALL_PATH_SRC "$CONF_INSTALL_PATH_SRC" Do_Store DIR_SOURCE "$DIR_SOURCE" Do_Store DIR_PKGS "$DIR_PKGS" return 0 else # FIXME: clean this mess up, also concerning FHS (/media el. al.) while [ 1 ]; do rm -f /source Do_Umount /mnt || continue if [ "`get_val -f /etc/lst.cnf CONF_COL_EDITION`" = "SBA" ]; then ANSWER="cdrom" else Choose --build Build_INSTALL_MEDIUM INSTALL_SOURCE CONF_INSTALL_MEDIUM || return 1 fi CONF_INSTALL_MEDIUM="$ANSWER" Debug "CONF_INSTALL_MEDIUM=<$CONF_INSTALL_MEDIUM>" Do_Store CONF_INSTALL_MEDIUM "$CONF_INSTALL_MEDIUM" Do_Umount /mnt || continue case $CONF_INSTALL_MEDIUM in path) CONF_INSTALL_DEV=path Ask_String DIR_SOURCE "/mnt" || continue Is_Known_Source $ANSWER || continue ;; floppy) Choose --other FLOPPY || continue CONF_INSTALL_DEV="`Get_Val CONF_FLOPPY${ANSWER}_DEV`" if [ -z "$CONF_INSTALL_DEV" ]; then CONF_INSTALL_DEV="/dev/fd0H1440" fi CONF_INSTALL_PATH_SRC= DIR_PKGS=/mnt ;; harddisk) Choose --menutitle ":CHOOSE_PARTITION_MENUTITLE:" --build "Build_PARTITION Src" PARTITION_SOURCE || continue CONF_INSTALL_DEV="$ANSWER" if [ -z "$CONF_INSTALL_DEV" ]; then continue ; fi Do_Mount -o ro $CONF_INSTALL_DEV /mnt || continue Is_Known_Source || continue ;; network|slip) # FIXME Do_Load_Driver filesystem nfs || continue : > $FILE_TMP_ERR Menu_Config_Nethost first if [ "$?" != "0" ]; then Error --file $FILE_TMP_ERR "Unable to configure ethernet device." continue fi Ask_HOST --num 1 NFS_SERVER || continue CONF_INSTALL_DEV="$ANSWER" Do_Store CONF_NFS_SERVER1_IP "$ANSWER" CONF_NFS_SERVER1_PATH="`Get_Val CONF_NFS_SERVER1_PATH`" if [ -n "$CONF_NFS_SERVER1_PATH" ]; then CONF_INSTALL_PATH_SRC="$CONF_NFS_SERVER1_PATH" fi Menu_Mount_NFS $CONF_NFS_SERVER1_IP /mnt $CONF_INSTALL_PATH_SRC || continue CONF_INSTALL_PATH_SRC="$ANSWER" Debug "After NFS mount" Do_Store CONF_NFS_SERVER1_PATH "$ANSWER" Is_Known_Source || continue ;; cdrom) Menu_Config_CD || continue sleep 2 CONF_INSTALL_DEV="$ANSWER" if [ -z "$CONF_INSTALL_DEV" ]; then continue ; fi ln -sf $ANSWER /dev/cdrom Do_Mount -t iso9660 -o ro $CONF_INSTALL_DEV /mnt || continue Do_Analyse_CD || continue Is_Known_Source || continue ;; tape) Menu_Config_Tape || continue CONF_INSTALL_DEV="$ANSWER" if [ -z "$CONF_INSTALL_DEV" ]; then continue ; fi # FIXME support tape installation Err_Not_Available continue CONF_INSTALL_PATH_SRC= DIR_PKGS= ;; esac ln -sf $DIR_SOURCE /source break done Do_Store CONF_INSTALL_DEV "$CONF_INSTALL_DEV" Do_Store CONF_INSTALL_PATH_SRC "$CONF_INSTALL_PATH_SRC" Do_Store DIR_SOURCE "$DIR_SOURCE" Do_Store DIR_PKGS "$DIR_PKGS" return 0 fi } Do_Reverse() { local rev_string="" local i if [ $# -eq 0 ]; then echo "" return 0 fi for i in $@ ; do rev_string="$i $rev_string" done echo $rev_string return 0 } Choose_Install_Target() { local partition local mountpoint local dummy local root_mounted local root_last local root_conf local try_root local mke2fs_retval local devs_under_root="" local devs_under_root_rev="" local auto_target="`Get_Val CONF_INSTALL_ROOT`" local i rm -f $FILE_TARGETS_SEL while [ 1 ]; do partition= mountpoint=/root dummy= root_mounted= root_last= root_conf= try_root= Debug "Choose_Install_Target called." if [ -f /tmp/root.fix ]; then CONF_INSTALL_ROOT="`cat /tmp/root.fix`" DIR_TARGET="`Get_Val DIR_TARGET`" else # start of not indended area... # check whether we have any target partition at all if [ -z "`sysinfo -C Dest --notitle --noheader --partition`" ]; then Error2 NO_TARGET_AVAILABLE ANSWER="new" return 0 fi # check whether there is something mounted on $mountpoint Check_Directory_Busy $mountpoint || root_mounted="$STATUS" CONF_INSTALL_ROOT= rm -f $FILE_ROOT_SEL.not touch $FILE_ROOT_SEL.not for i in $root_mounted $root_last $root_conf ; do cat $FILE_ROOT_SEL.not | fgrep -x "$i" >/dev/null && continue # ask whether we want to use this # FIXME: hardcoded strings $CMD_BOX --default "j" --bool "The partition $i ; :ASK_USE_AS_ROOT_PARTITION:" 2> $FILE_TMP_ANSWER || return 1 if [ "`cat $FILE_TMP_ANSWER`" = "0" ]; then try_root="$i" break else echo "$i" >> $FILE_ROOT_SEL.not fi done rm -f $FILE_ROOT_SEL.not # first unmount any partitions below /root in reverse order devs_under_root="`mount | sed -n '/on \/root\//p' | cut -d' ' -f 1`" if [ -n "$devs_under_root" ]; then devs_under_root_rev="`Do_Reverse "$devs_under_root"`" if [ -n "$devs_under_root_rev" ]; then for i in $devs_under_root_rev ; do Do_Umount $i done fi fi # unmount old partitions touch $FILE_TARGETS_SEL for i in `cat $FILE_TARGETS_SEL` ; do # do not unmount new root partition if [ "$i" = "$CONF_INSTALL_ROOT" ]; then continue fi # do not unmount source device if [ "$i" = "$CONF_INSTALL_DEV" ]; then continue fi # do not unmount swap partitions if [ -f $FILE_SWAP_SEL ]; then fgrep -x "$i" $FILE_SWAP_SEL >/dev/null if [ $? -eq 0 ]; then continue fi fi Do_Umount $i done # ask for target root partition while [ 1 ]; do CONF_INSTALL_ROOT= if [ -n "$try_root" ]; then CONF_INSTALL_ROOT="$try_root" try_root= fs_type="`mount | sed -n '/on \/root /s/.*type \([^ ]*\) .*/\1/p'`" break else # umsdos source and target IMPOSSIBLE! Debug "FTS: appended '$CONF_INSTALL_DEV'" echo "$CONF_INSTALL_DEV" >> $FILE_TARGETS_SEL Choose --menutitle ":CHOOSE_PARTITION_MENUTITLE:" --build "Build_PARTITION --exclude $FILE_TARGETS_SEL DestSorted" PARTITION_ROOT $auto_target || return 1 if [ -z "$ANSWER" ]; then Error "no partition specified!" continue else CONF_INSTALL_ROOT="$ANSWER" fi fi partid="`Get_Partition_Info --id $CONF_INSTALL_ROOT`" if [ "$partid" = "1" -o "$partid" = "4" -o "$partid" = "6" ]; then Warn "Partition $CONF_INSTALL_ROOT ; :WARN_USE_UMSDOS:" || continue Do_Mount -t umsdos $CONF_INSTALL_ROOT /root || continue fs_type="$ANSWER" if [ "$fs_type" = "umsdos" ]; then if [ -d /root/linux ]; then Ask_Bool --pretext "Partition $CONF_INSTALL_ROOT ; " DELETE_LINUX_SUBDIR || return 1 if [ "$ANSWER" = "0" ]; then rm -fr /root/linux else Warn "Partition $CONF_INSTALL_ROOT ; :WARN_NOT_USABLE_AS_ROOT:" return 1 fi fi mkdir -p /root/linux/etc touch /root/linux/etc/rc prep_use UMSDOS umssync -r99 -v- /root/linux >>$FILE_LOG_HISTORY 2>&1 end_use UMSDOS DIR_TARGET=/root/linux mkdir -p $DIR_TARGET/var/adm/LST/log PATH=${PATH}:$DIR_TARGET/bin:$DIR_TARGET/usr/bin:$DIR_TARGET/sbin:$DIR_TARGET/usr/sbin export PATH break else Error "DOS Partition was not mounted as type umsdos but as type $fs_type" Do_Umount /root continue fi elif [ "$partid" = "131" ]; then # do not format partitions that contain a swap file ROOT_INITIALIZED=0 Check_Found "$CONF_INSTALL_ROOT" "$FILE_SWAP_SEL" if [ $? -ne 0 ]; then # otherwise force format for root partition Do_Umount $CONF_INSTALL_ROOT || continue Do_Umount /root || continue Menu_Call_Mke2fs "$CONF_INSTALL_ROOT" || continue fi Do_Mount -t ext2 $CONF_INSTALL_ROOT /root || continue fs_type="$ANSWER" DIR_TARGET=/root mkdir -p $DIR_TARGET/var/adm/LST/log break else Error "a partition with type <$partid> can not be used as root-partition!" continue fi done Debug "FTS: appending '$CONF_INSTALL_ROOT'" echo "$CONF_INSTALL_ROOT" >> $FILE_TARGETS_SEL echo "$CONF_INSTALL_ROOT" > $FILE_ROOT_SEL # we don't need to ask for a mount point here as it's implicit for root mkdir -p $DIR_TARGET/proc mkdir -p $DIR_TARGET/etc echo "$CONF_INSTALL_ROOT / $fs_type defaults 0 1" > $DIR_TARGET/etc/fstab echo "/proc /proc proc defaults 0 0" >> $DIR_TARGET/etc/fstab if [ -s $FILE_SWAP_SEL ]; then if [ -s /tmp/fstab.tmp ]; then cat /tmp/fstab.tmp >> $DIR_TARGET/etc/fstab else echo "`cat $FILE_SWAP_SEL` none swap defaults 0 0" >> $DIR_TARGET/etc/fstab fi Debug "FTS: appending '$FILE_SWAP_SEL'" cat $FILE_SWAP_SEL >> $FILE_TARGETS_SEL fi chmod 644 $DIR_TARGET/etc/fstab # end of not indended area fi Do_Store CONF_INSTALL_ROOT "$CONF_INSTALL_ROOT" Do_Store DIR_TARGET "$DIR_TARGET" # ask for additional target partitions while [ 1 ]; do if [ -z "`Build_PARTITION --exclude $FILE_TARGETS_SEL Linux`" ];then Debug --diskonly "No ADDITIONAL partitions available" return 0 fi Ask_Bool MORE_TARGET_PARTITIONS n || break if [ "$ANSWER" = "1" ]; then return 0 fi Choose --menutitle ":CHOOSE_PARTITION_MENUTITLE:" --build "Build_PARTITION --exclude $FILE_TARGETS_SEL Linux" PARTITION_OTHER if [ -z "$ANSWER" ]; then Error "no partition specified!" continue elif [ "$ANSWER" = "new" ]; then return 0 else partition="$ANSWER" fi while [ 1 ]; do Ask_String MOUNTPOINT || continue if [ -n "$ANSWER" ]; then # make PATH absolute echo "$ANSWER" | cut -c 1 | fgrep '/' >/dev/null || ANSWER="/$ANSWER" break else Error "no mount point specified" fi done mountpoint="$ANSWER" partid="`Get_Partition_Info --id $partition`" if [ "$partid" = "131" ]; then Menu_Call_Mke2fs "$partition" mke2fs_retval=$? if [ $mke2fs_retval -eq 2 ] ; then # we did not want to format it # can we mount it? mkdir -p /tmp/mnt mount -r -t ext2 $partition /tmp/mnt >/dev/null 2>&1 if [ $? -eq 0 ]; then umount /tmp/mnt >/dev/null 2>&1 Ask_Bool --pretext "Partition $partition ; " MOUNT_INSTEAD_FORMAT || continue if [ "$ANSWER" = "0" ]; then Warn ":WARN_PARTITION_NOT_FORMATED:" || continue else continue fi fi else if [ $mke2fs_retval -ne 0 ] ; then continue ; fi fi fi mkdir -p ${DIR_TARGET}$mountpoint Do_Mount "$partition" ${DIR_TARGET}$mountpoint || continue fs_type="$ANSWER" echo "$partition" > $FILE_TARGETS_SEL.tmp if [ ! -f $FILE_TARGETS_SEL ]; then Panic "no root partition specified!" return 1 fi cat $FILE_TARGETS_SEL >> $FILE_TARGETS_SEL.tmp mv $FILE_TARGETS_SEL.tmp $FILE_TARGETS_SEL Debug "FTS: setting '`cat $FILE_TARGETS_SEL`'" echo "$partition $mountpoint $fs_type defaults 0 2" >> $DIR_TARGET/etc/fstab mkdir -p $DIR_TARGET/var/adm/LST/log done # other choose loop done # target choose loop return 0 } # checks if CD is valid and writes version to Debug # Do_Analyse_CD() { local cd_label= local smarties_retval= if [ -x /usr/lib/LST/smarties ]; then /usr/lib/LST/smarties $CONF_INSTALL_DEV > /tmp/.version smarties_retval=$? cd_label="`cat /tmp/.version`" # continue if smarties has internal problems (driver errors on seek/read) if [ $smarties_retval -eq 3 ]; then return 0 fi # abort if unknown CD was detected if [ -z "$cd_label" ]; then Debug "CDROM is unknown" #Do_Umount /mnt Error2 NO_ORIG_CD #Ask_Bool CONTINUE_INSTALL n #if [ "$ANSWER" = "0" ]; then return 0 #fi #return 1 else Debug "CDROM is <$cd_label>" if [ "`get_val -f /etc/lst.cnf CONF_COL_EDITION`" != "SBA" ]; then Msg ":INFO_KNOWN_CD_DETECTED: ; ; $cd_label" if [ "$cd_label" = "Toolbox Linux Sonderheft 1997" ]; then Msg ":INFO_TOOLBOX_CD:" fi fi fi # abort if a non install CD was inserted if [ $smarties_retval -ne 0 ]; then Debug "wrong CD inserted" Do_Umount /mnt Error2 NO_INSTALL_CD return 1 else return 0 fi fi } MountModulesFloppy() { local modpath="/lib/modules" local success= mount /floppy >/dev/null 2>&1 while [ 1 ]; do if [ -d /floppy/$modpath ]; then success=true break else umount /floppy >/dev/null 2>&1 Msg ":DO_INSERT_MODULES_FLOPPY:" || break mount /floppy >/dev/null 2>&1 fi done if [ -n "$success" ]; then return 0 else return 1 fi } # checks if source path is valid and sets # CONF_INSTALL_PATH_SRC # DIR_BIN # DIR_DATA # DIR_SOURCE # DIR_PKGS # Is_Known_Source() { local prefix="/mnt" # during install the source is mounted under /mnt local suffix="install/basis1/basis1.idx" if [ $# -gt 0 ]; then prefix="$1" # later we may specify a different path fi while [ 1 ]; do export DIR_BIN= export DIR_DATA= export DIR_PKGS= if [ -d $prefix/install -a -d $prefix/bin -a -d $prefix/data ]; then Debug "found Caldera OpenLinux / LST Power Linux" CONF_INSTALL_PATH_SRC="" DIR_SOURCE="$prefix" DIR_DATA="$DIR_SOURCE/data" DIR_BIN="$DIR_SOURCE/bin" DIR_PKGS="$DIR_SOURCE/install" return 0 elif [ -f $prefix/live -a $prefix/col/data/cd1 ]; then Debug "found Caldera OpenLinux 2.x CD 1" CONF_INSTALL_PATH_SRC="col" DIR_SOURCE="$prefix/$CONF_INSTALL_PATH_SRC" DIR_DATA="$DIR_SOURCE/data" if [ -f $DIR_DATA/pkgs.db ]; then cp -a $DIR_DATA/pkgs.db $FILE_PKGS_DATA fi if [ -f $DIR_DATA/us/pkgs.idx ]; then cp -a $DIR_DATA/us/pkgs.idx $FILE_PKGS_INDEX fi DIR_BIN="$DIR_SOURCE/bin" DIR_PKGS="$DIR_SOURCE/install" return 0 elif [ -f $prefix/col/data/cd1 ]; then Debug "found Caldera OpenLinux 1.2 CD 1" CONF_INSTALL_PATH_SRC="col" DIR_SOURCE="$prefix/$CONF_INSTALL_PATH_SRC" DIR_DATA="$DIR_SOURCE/data" if [ -f $DIR_DATA/pkgs.db ]; then cp -a $DIR_DATA/pkgs.db $FILE_PKGS_DATA fi DIR_BIN="$DIR_SOURCE/bin" DIR_PKGS="$DIR_SOURCE/install" return 0 elif [ -f $prefix/col/data/cd2 ]; then Debug "found Caldera OpenLinux 1.2 CD 2" CONF_INSTALL_PATH_SRC="col" DIR_SOURCE="$prefix/$CONF_INSTALL_PATH_SRC" DIR_DATA="$DIR_SOURCE/data" if [ -f $DIR_DATA/pkgs.db ]; then cp -a $DIR_DATA/pkgs.db $FILE_PKGS_DATA fi DIR_BIN="$DIR_SOURCE/bin" DIR_PKGS="$DIR_SOURCE/install" return 0 elif [ -d $prefix/col/lib ]; then Debug "found Caldera OpenLinux 1.2" CONF_INSTALL_PATH_SRC="col" DIR_SOURCE="$prefix/$CONF_INSTALL_PATH_SRC" DIR_DATA="$DIR_SOURCE/data" DIR_BIN="$DIR_SOURCE/bin" DIR_PKGS="$DIR_SOURCE/install" return 0 elif [ -f $prefix/col/$suffix ]; then Debug "found Caldera OpenLinux 1.1" INSTALL_MODE=LST CONF_INSTALL_PATH_SRC="col" DIR_SOURCE="$prefix/$CONF_INSTALL_PATH_SRC" DIR_DATA="$DIR_SOURCE/data" DIR_BIN="$DIR_SOURCE/bin" DIR_PKGS="$DIR_SOURCE/install" return 0 elif [ -f $prefix/col_10/$suffix ]; then Debug "found Caldera OpenLinux 1.0" CONF_INSTALL_PATH_SRC="col_10" DIR_SOURCE="$prefix/$CONF_INSTALL_PATH_SRC" DIR_DATA="$DIR_SOURCE/data" DIR_BIN="$DIR_SOURCE/bin" DIR_PKGS="$DIR_SOURCE/install" return 0 elif [ -f $prefix/col_10b/$suffix ]; then Debug "found Caldera OpenLinux 1.0 Beta Preview" CONF_INSTALL_PATH_SRC="col_10b" DIR_SOURCE="$prefix/$CONF_INSTALL_PATH_SRC" DIR_DATA="$DIR_SOURCE/data" DIR_BIN="$DIR_SOURCE/bin" DIR_PKGS="$DIR_SOURCE/install" return 0 elif [ -f $prefix/lst_22/$suffix ]; then Debug "found LST 2.2 Power Linux" CONF_INSTALL_PATH_SRC="lst_22" DIR_SOURCE="$prefix/$CONF_INSTALL_PATH_SRC" DIR_DATA="$DIR_SOURCE/data" DIR_BIN="$DIR_SOURCE/bin" DIR_PKGS="$DIR_SOURCE/install" return 0 elif [ -f $prefix/lst_22b/$suffix ]; then Debug "found LST 2.2 Beta Preview" CONF_INSTALL_PATH_SRC="lst_22b" DIR_SOURCE="$prefix/$CONF_INSTALL_PATH_SRC" DIR_DATA="$DIR_SOURCE/data" DIR_PKGS=$DIR_SOURCE return 0 elif [ -f $prefix/lst_21/$suffix ]; then Debug "found LST 2.1 Power Linux" CONF_INSTALL_PATH_SRC="lst_21" DIR_SOURCE="$prefix/$CONF_INSTALL_PATH_SRC" DIR_DATA="$DIR_SOURCE" DIR_PKGS=$DIR_SOURCE return 0 elif [ -f $prefix/Packages/RPMS/calderize-1.0-1.i386.rpm ]; then Debug "found Caldera Network Desktop 1.0" CONF_INSTALL_PATH_SRC="Packages" DIR_SOURCE="$prefix/$CONF_INSTALL_PATH_SRC" DIR_PKGS=$DIR_SOURCE export CND10_MODE=true Msg ":INFO_CND10_WILL_REQUIRE_MODULES_FLOPPY:" MountModulesFloppy return 0 else Debug "no known Distribution found under <$prefix>" Error "<$prefix> ; :ERR_INVALID_SOURCE_PATH:" Ask_String DIR_SOURCE "$prefix" || return 1 prefix="$ANSWER" fi done } Do_Calc_Freespace() { local i= local PathRegexProof local master_mntpoint local sub_mntpoints FREESPACE=0 rm -f $FILE_TMP_VAL if [ $# -eq 0 ]; then PathRegexProof="\/" else PathRegexProof="`echo "$1" | sed 's/\//\\\\\//'`" fi Debug "PathRegexProof=<$PathRegexProof>" # get list of mountpoints for the specified path master_mntpoint="`mount | sed -n '/on '${PathRegexProof}' /p' | cut -d' ' -f 3`" Debug "master_mntpoint=<$master_mntpoint>" if [ -n "$master_mntpoint" ]; then df $master_mntpoint | fgrep '%' | cut -c 37-45 > $FILE_TMP_VAL else # specified path is not a directory. use simple df on its fs df $1 | fgrep '%' | cut -c 37-45 > $FILE_TMP_VAL fi sub_mntpoints="`mount | sed -n '/on '${PathRegexProof}'\//p' | cut -d' ' -f 3`" Debug "sub_mntpoints=<$sub_mntpoints>" if [ -n "$sub_mntpoints" ]; then for i in $sub_mntpoints ; do df $i | fgrep '%' | cut -c 37-45 >> $FILE_TMP_VAL done fi touch $FILE_TMP_VAL for i in `cat $FILE_TMP_VAL` ; do FREESPACE="`do_calc $FREESPACE + $i`" done FREESPACE="`do_calc $FREESPACE \* 1024`" if [ -z "$FREESPACE" ]; then FREESPACE=0 fi Debug "summarized FREESPACE=<$FREESPACE>" export FREESPACE return 0 } # calculate space requirements for a given list of packages Do_Calc_Needspace() { export NEEDSPACE=0 local sellist=$1 NEEDSPACE="`build_menu -t $sellist -d $FILE_PKGS_DATA -S | cut -d':' -f 7`" NEEDSPACE="`do_calc $NEEDSPACE \* 1024`" Debug "NEEDSPACE => <$NEEDSPACE>" } Do_Find_File_To_Pkg() { local f_name=Do_Find_File_To_Pkg local f_args=1 # (pkg) -> PKG_FILE local tmpfile=/tmp/pkginfo.$$ local pkg="$1" local vers local subdir local pkgpath="$DIR_PKGS/RPMS" export PKG_FILE=unknown Check_Args $f_name $f_args $# "$@" || return 255 # get version from pkgs.db db_printf -n -m ":1:$pkg:" -p ":-8:" -f $FILE_PKGS_DATA | sed 's/[ ]*//g' > $tmpfile if [ -s $tmpfile ]; then read vers < $tmpfile fi rm -f $tmpfile Debug "Do_Find_File_To_Pkg $1 -> $pkgpath/$pkg-$vers.${RPMBINEXT}.rpm" if [ -f $pkgpath/$pkg-$vers.${RPMBINEXT}.rpm ]; then # first we look for rpm files PKG_FILE="$pkgpath/$pkg-$vers.${RPMBINEXT}.rpm" Debug "found PKG_FILE=$PKG_FILE (rpm case)" return 0 else # support harddisk installs from msdos partitions # get subdir from pkgs.db db_printf -n -m ":1:$pkg:" -p ":-6:" -f $FILE_PKGS_DATA | sed 's/[ ]*//g' > $tmpfile if [ -s $tmpfile ]; then read subdir < $tmpfile fi rm -f $tmpfile Debug "Trying trans.tbl lookup for $pkgpath/$pkg-$vers.${RPMBINEXT}.rpm" Do_Lookup_Trans_Tbl $pkgpath/$pkg-$vers.${RPMBINEXT}.rpm if [ $? -eq 0 ]; then PKG_FILE="$ANSWER" else if [ -d $DIR_PKGS/$subdir ]; then pkgpath=$DIR_PKGS/$subdir fi Debug "Trying trans.tbl lookup for $pkgpath/$pkg-$vers.${RPMBINEXT}.rpm" Do_Lookup_Trans_Tbl $pkgpath/$pkg-$vers.${RPMBINEXT}.rpm if [ $? -eq 0 ]; then PKG_FILE="$ANSWER" else Error "$pkgpath/$pkg-$vers.${RPMBINEXT}.rpm ; :ERR_FILE_NOT_FOUND:" echo "$pkgpath/$pkg-$vers.${RPMBINEXT}.rpm not found" >> /root/tmp/LST/install_error Ask_Bool ABORT_INSTALL y if [ "$ANSWER" = "0" ]; then Do_Reboot fi Is_Expert if [ $? -eq 0 ]; then echo "Enter Path" read PKG_FILE export PKG_FILE fi fi fi return 1 fi } Do_Find_Pkg_To_File() { local f_name=Do_Find_Pkg_To_File local f_args=1 # (file) -> PKG_NAME local file="$1" Get_Pkg_Type $file || return 1 case $PKG_TYPE in rpm) # rpm package if [ "$CND10_MODE" = "true" ]; then # old rpmextr version rpmextr --shell $file | fgrep PKG_NAME > $FILE_TMP_VAL . $FILE_TMP_VAL else # new rpmextr version PKG_NAME="`rpmextr --tag=name $file`" fi ;; esac export PKG_NAME Debug "Do_Find_Pkg_To_File $1 -> $PKG_NAME" return 0 } # FIXME: this is a really bad hack. We need dependencies... Do_Sort_Pkgs() { local i local first_pkgs="DEV MAKEDEV dev grep sed ld.so glibc libc aout-libs bash lisa fileutils sh-utils textutils util-linux make kde2compat" # resort pkglist to make sure essential packages are installed first Debug "resorting selected packages" rm -f $FILE_PKGS_SEL.tmp touch $FILE_PKGS_SEL touch $FILE_PKGS_SEL.tmp for i in $first_pkgs `cat $FILE_PKGS_SEL` ; do fgrep -x $i $FILE_PKGS_SEL > /dev/null if [ $? -eq 0 ]; then fgrep -x $i $FILE_PKGS_SEL.tmp > /dev/null if [ $? -ne 0 ]; then echo "$i" >> $FILE_PKGS_SEL.tmp fi fi done mv $FILE_PKGS_SEL.tmp $FILE_PKGS_SEL } Do_Sort_Series() { local i # resort serieslist to make sure basis and xbasis are installed first mv $FILE_SERIES_SEL $FILE_SERIES_SEL.tmp touch $FILE_SERIES_SEL for i in $LST_SERIES ; do fgrep $i $FILE_SERIES_SEL.tmp > /dev/null if [ $? -eq 0 ]; then echo "$i" >> $FILE_SERIES_SEL fi done rm -f $FILE_SERIES_SEL.tmp } Do_Transfer_Minimum() { local i mkdir -p $DIR_TARGET/bin cp -a /bin/cat /bin/mkdir /bin/basename $DIR_TARGET/bin mkdir -p $DIR_TARGET/lib cp -a /lib/libc.so.4.5.24 $DIR_TARGET/lib ln -sf libc.so.4.5.24 $DIR_TARGET/lib/libc.so.4 mkdir -p $DIR_TARGET/etc/rc.d for i in rc0.d rc1.d rc2.d rc3.d rc4.d rc5.d rc6.d ; do mkdir -p $DIR_TARGET/etc/rc.d/$i done } Do_PHI_Complete_Pkgs() { local dep_matrix=$DIR_LIVE/lizard/share/apps/lizard/packages local my_sort="sort" local my_uniq="uniq" local i if [ ! -r $dep_matrix ]; then Debug "Did not find a dependecy matrix under $dep_matrix. Skip." return 1 else Debug "PHI completing pkgs with precalculated dependency matrix" fi # try to survive if we don't have sort or unique available sort --version > /dev/null 2>&1 || my_sort='cat -' uniq --version > /dev/null 2>&1 || my_uniq='cat -' touch $FILE_PKGS_SEL for i in `cat $FILE_PKGS_SEL` ; do echo "$i" sed -n "/^${i}:/p" $dep_matrix | \ cut -d':' -f 4 | \ sed '{ s/,/ /g s/ /\ /g }' done | $my_sort | $my_uniq > $FILE_PKGS_SEL.tmp mv $FILE_PKGS_SEL.tmp $FILE_PKGS_SEL return 0 } Do_Pkg_Install() { local myseries= local mydisk= local pkgname= local pkgfile= local i Debug "Do_Pkg_Install <$@>" Has_Source || return 1 Has_Target_Path || return 1 Has_Selections || return 1 prep_use INSTALL || return 1 prep_use RPM_INSTALL || return 1 Info ":INFO_WAIT:" Do_Sort_Pkgs Do_Sort_Series build_menu -t $FILE_PKGS_SEL -d $FILE_PKGS_DATA -n -p ":5:" > $FILE_DISKS_SEL if [ "`get_val -f /etc/lst.cnf CONF_COL_EDITION`" != "SBA" ]; then Msg2 PKG_INSTALL || continue fi Info ":INFO_WAIT:" # After this point there is no way to stop the installation # and to step back so we can safely delete and move some things # to avoid running out of ramdisk space # Copy minimal files from ramdisk to root Do_Transfer_Minimum # Delete the unused modules from the ramdisk Delete_unused_modules # switch the log area Do_Switch_Log_Area # mount /proc additionally under $DIR_TARGET to make sure # the /dev/core symlink points to something usefull mkdir -p $DIR_TARGET/proc mount -t proc /proc $DIR_TARGET/proc export DIR_LOG_PKGS=$DIR_TARGET/install export DIR_LOG_INSTALLED=$DIR_LOG_PKGS/installed export DIR_LOG_CATALOG=$DIR_LOG_PKGS/catalog export DIR_LOG_CONTENTS=$DIR_LOG_PKGS/contents export DIR_LOG_CONFLICTS=$DIR_LOG_PKGS/conflicts export DIR_LOG_SCRIPTS=$DIR_LOG_PKGS/scripts export DIR_LOG_DISKS=$DIR_LOG_PKGS/disks export DIR_LOG_SAVED=$DIR_LOG_PKGS/saved export DIR_LOG_REPLACED=$DIR_LOG_PKGS/replaced export DIR_LOG_DELETED=$DIR_LOG_PKGS/deleted export DIR_LOG_ERRORS=$DIR_LOG_PKGS/errors for logdir in $DIR_LOG_ANALYSE $DIR_LOG_LOG $DIR_LOG_INSTALLED $DIR_LOG_SCRIPTS $DIR_LOG_DISKS $DIR_LOG_CATALOG $DIR_LOG_CONTENTS $DIR_LOG_CONFLICTS $DIR_LOG_SAVED $DIR_LOG_REPLACED $DIR_LOG_DELETED $DIR_LOG_ERRORS ; do mkdir -p $logdir done Get_Install_Stat # first look for base directory (COL, LST 2.2, CND 1.0, RedHat 3.0.3) if [ -f $DIR_DATA/framework.cgz ]; then Debug "file $DIR_DATA/framework.cgz found" Debug "using cpio install mode" Debug "Installing framework.cgz" Do_Uncpio $DIR_DATA/framework.cgz || return 1 for i in $DIR_TARGET/opt/{bin,man} ; do if [ ! -d $DIR_TARGET/$i ]; then mkdir -p $DIR_TARGET/$i fi done for i in passwd shadow group hosts sysconfig/network; do if [ ! -r $DIR_TARGET/etc/$i -a -r $DIR_TARGET/etc/${i}- ]; then mv $DIR_TARGET/etc/${i}- $DIR_TARGET/etc/$i fi done rm -vf $DIR_TARGET/etc/*- $DIR_TARGET/etc/sysconfig/*- fi # prefer install driven by pkgs.sel (COL 1.0, CND 1.0, RedHat 3.0.3) if [ -d $DIR_PKGS/RPMS ]; then Debug "file $DIR_PKGS/RPMS found" Debug "using RPMS install mode" for pkgname in `cat $FILE_PKGS_SEL` ; do Do_Find_File_To_Pkg $pkgname pkgfile="$PKG_FILE" Debug "Install $pkgname ($pkgfile)" Do_Raw_rpm_Install $pkgfile $pkgname done if [ "$INSTALL_MODE" = "OpenLinux" ]; then Fix_12_Alpha before_postin Do_All_Postin Fix_12_Alpha after_postin fi return 0 # support LST install (COL, LST 2.2, LST 2.2b, LST 2.1) elif [ -f $DIR_PKGS/basis1/basis1.idx ]; then Debug "file $DIR_PKGS/basis1/basis1.idx found" Debug "using COL/LST series install mode" for myseries in `cat $FILE_SERIES_SEL` ; do # FIXME: hardcoded maximum of 16 disks per series for disknum in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ; do mydisk=$myseries$disknum fgrep -x $mydisk $FILE_DISKS_SEL > /dev/null if [ $? -ne 0 ]; then continue ; fi Debug "installing LST disk $mydisk" for pkgfile in $DIR_PKGS/$mydisk/*.rpm ; do if [ ! -f $pkgfile ]; then continue ; fi Do_Find_Pkg_To_File $pkgfile pkgname="$PKG_NAME" fgrep -x $pkgname $FILE_PKGS_SEL > /dev/null if [ $? -ne 0 ]; then Debug "$pkgname is not selected. Skipping." continue fi Do_Raw_rpm_Install $pkgfile $pkgname done done done return 0 else Debug "no idea how to install $DIR_PKGS" return 1 fi return 0 } Check_Pkg_Installed() { local p="$1" # check for rpm package rpm -qi $p > /dev/null 2> /dev/null if [ $? -eq 0 ]; then ANSWER=rpm return 0 fi return 1 } Do_Pkg_Remove_RPM() { local retval local p="$1" rpm --nodeps -e $p 2> $FILE_TMP_ERR retval=$? if [ $retval -eq 0 ]; then echo "`date` removal of pkg $p was ok ($retval)" >> $DIR_TARGET/var/adm/LST/log/remove.success return 0 else echo "`date` removal of pkg $p failed ($retval)" >> $DIR_TARGET/var/adm/LST/log/remove.failed Error --file $FILE_TMP_ERR "rpm removal of $p failed" return 1 fi } Do_Pkg_Remove_TGZ() { local p="$1" if [ -f $DIR_LOG_INSTALLED/$p ]; then ( cd $DIR_TARGET; rm -f `cat $DIR_LOG_INSTALLED/${p}` ) fi } Do_Pkg_Remove_META() { local p="$1" for s in doinst.sh dobefore.sh doafter.sh ; do if [ -f $DIR_LOG_SCRIPTS/${p}.${s} ]; then History_Install "removing $ptype package $p (${p}.${s}) ..." rm -f $DIR_LOG_SCRIPTS/${p}.${s} fi done History_Install "removing $ptype package $p ($DIR_LOG_INSTALLED/${p}) ..." rm -f $DIR_LOG_INSTALLED/${p} } # deinstallation of a package by means of a contents file # Do_Pkg_Remove() { local f_name=Do_Pkg_Remove local f_args=1 # (pkg_name) -> local s local p local ptype Check_Args $f_name $f_args $# "$@" || return 255 p="$1" Check_Pkg_Installed $p if [ $? -ne 0 ]; then Error "${p} ; :ERR_PKG_NOT_INSTALLED:" return 1 fi ptype="$ANSWER" History_Install "removing $ptype package $p (files) ..." case $ptype in rpm) Do_Pkg_Remove_RPM $p ;; esac Do_Pkg_Remove_META $p History_Install "removing $ptype package $p (done)" } Do_Uncpio() { local retval= mkdir -p $DIR_TARGET/tmp/LST echo "#!/bin/sh" > /tmp/LST/do_uncpio echo "cd $DIR_TARGET || exit 42" >> /tmp/LST/do_uncpio echo 'cat $1 | gzip -d | cpio -ivumd && exit 0' >> /tmp/LST/do_uncpio chmod 755 /tmp/LST/do_uncpio sync /tmp/LST/do_uncpio $1 2> $DIR_LOG_INSTALLED/`basename $1 .cgz` && return 0 History_Install "do_uncpio $1 exited with error code <$?> (bad package ?)" Debug_Stop return 1 } Do_4_Digit() { local was="$1" local now= was="`echo $was | sed 's/^[0]*//'`" if [ $was -gt 999 ]; then now="$was" elif [ $was -gt 99 ]; then now="0$was" elif [ $was -gt 9 ]; then now="00$was" else now="000$was" fi echo "$now" return 0 } Do_Unrpm() { local retval= local num= local num4digit= mkdir -p $DIR_TARGET/tmp/LST echo "#!/bin/sh" > /tmp/LST/do_unrpm if [ "$DIR_TARGET" = '/' ]; then echo "rpm -i --nodeps $1 2> $FILE_TMP_ERR && exit 0" >> /tmp/LST/do_unrpm else if [ "$INSTALL_MODE" = "OpenLinux" ]; then if [ -f /source/data/use-force ]; then echo "rpm -i --force --nodeps --noscripts --root $DIR_TARGET $1 2> $FILE_TMP_ERR && exit 0" >> /tmp/LST/do_unrpm else echo "rpm -i --nodeps --noscripts --root $DIR_TARGET $1 2> $FILE_TMP_ERR && exit 0" >> /tmp/LST/do_unrpm fi else if [ "$CND10_MODE" = "true" ]; then echo "cd $DIR_TARGET || exit 1" >> /tmp/LST/do_unrpm echo "rpmq -i $1 2> $FILE_TMP_ERR && exit 0" >> /tmp/LST/do_unrpm else echo "rpm -i --force --root $DIR_TARGET $1 2> $FILE_TMP_ERR && exit 0" >> /tmp/LST/do_unrpm fi fi fi echo "exit 1" >> /tmp/LST/do_unrpm chmod 755 /tmp/LST/do_unrpm # If we run from the lisa live filesystem then use tty4 for progress echo if [ -n "`sed -n '/^er=/p' /tmp/cmdline | fgrep text`" ]; then cat /tmp/LST/do_unrpm > /dev/tty4 else cat /tmp/LST/do_unrpm > /dev/tty7 fi sync /tmp/LST/do_unrpm $1 2> $DIR_LOG_ERRORS/$PKG_NAME retval=$? # remove empty error logs if [ ! -s $DIR_LOG_ERRORS/$PKG_NAME ]; then rm -f $DIR_LOG_ERRORS/$PKG_NAME fi if [ $retval -ne 0 ]; then History_Install "do_unrpm $1 exited with error code <$retval> (bad package ?)" # Debug_Stop Error --file $FILE_TMP_ERR "rpm install of $1 failed" return $retval else rm -f $FILE_TMP_ERR fi # extract post install script rpmextr --post $1 > $DIR_TARGET/install/doinst.sh if [ ! -s $DIR_TARGET/install/doinst.sh ]; then rm -f $DIR_TARGET/install/doinst.sh else chmod 755 $DIR_TARGET/install/doinst.sh cp -a $DIR_TARGET/install/doinst.sh $DIR_TARGET/install/scripts/$PKG_NAME.postin if [ "$DIR_TARGET" != '/' ]; then if [ "$INSTALL_MODE" = "OpenLinux" ]; then mkdir -p $DIR_TARGET/install/postin num="`do_calc $PKG_NUM_DONE + 1 `" num4digit="`Do_4_Digit $num`" cp -a $DIR_TARGET/install/doinst.sh $DIR_TARGET/install/postin/${num4digit}.${PKG_NAME} fi fi fi if [ "$CND10_MODE" != "true" ]; then rm -f $DIR_TARGET/install/doinst.sh # extract short and long listings rpm -ql $PKG_NAME > $DIR_TARGET/install/installed/$PKG_NAME rpm -qlv $PKG_NAME > $DIR_TARGET/install/contents/$PKG_NAME fi return 0 } Do_Untar() { local contents=$DIR_TARGET/tmp/LST/C local files=$DIR_TARGET/tmp/LST/F local retval= local failure= mkdir -p $DIR_TARGET/tmp/LST echo "#!/bin/sh" > /tmp/LST/do_untar echo "cd $DIR_TARGET || exit 1" >> /tmp/LST/do_untar echo 'tar -zxvvlpf $1 $2 && exit 0' >> /tmp/LST/do_untar chmod 755 /tmp/LST/do_untar while [ 1 ]; do rm -f $contents $files sync /tmp/LST/do_untar $1 $2 > $contents 2> $FILE_TMP_ERR retval=$? if [ $retval -ne 0 ]; then if [ -z "$failure" ]; then History_Install "tar $@ exited with error code <$retval> (bad package ?)" History_Install "retrying tar $@ ..." failure=true else Error "$PKG_NAME ; :ERR_BAD_PKG:" || return 1 failure= fi else if [ -n "$failure" ]; then History_Install "retry of tar $@ completed successfully." fi cp -a $contents $DIR_LOG_CONTENTS/$PKG_NAME sed -e '/\/$/d' -e 's/.* //' $contents | cut -d' ' -f 8 > $DIR_LOG_INSTALLED/$PKG_NAME return 0 fi done } Do_Save_Conflicts() { local contents=$DIR_TARGET/tmp/LST/C local files=$DIR_TARGET/tmp/LST/F Debug "checking for conflicts" for dummy in `cat $files`; do if [ -f $DIR_TARGET/$dummy ]; then Do_Log -f $DIR_LOG_CONFLICTS/$PKG_NAME "$dummy" if [ "$PKG_SAVE" = "true" ]; then Do_Log -f $DIR_LOG_SAVED/$PKG_NAME "$dummy.before.$CONF_LST_VERSION" History_Install "$dummy saved as $dummy.before.$CONF_LST_VERSION" ln -f $DIR_TARGET/$dummy $DIR_TARGET/$dummy.before.$CONF_LST_VERSION fi rm -f $DIR_TARGET/$dummy Do_Log -f $DIR_LOG_REPLACED/$PKG_NAME "$dummy" History_Install "$dummy will be replaced" fi done } Fix_col22() { # remove postin scripts that currently hang rm -f $DIR_TARGET/install/postin/*.kpilot mkdir -p $DIR_TARGET/var/run mkdir -p $DIR_TARGET/var/lock mkdir -p $DIR_TARGET/var/log } # FIXME12: this whole function should disappear Fix_12_Alpha() { local uname_r local uname_v if [ "$1" = "target_mounted" ]; then # create linux symlink if not there mkdir -p $DIR_TARGET/usr/src if [ ! -L $DIR_TARGET/usr/src/linux ]; then ln -s linux-"`uname -r`" $DIR_TARGET/usr/src/linux fi elif [ "$1" = "before_postin" ]; then if [ -f /source/data/use-mini-lisa ]; then # use mini-lisa because new one is under construction cp -a $DIR_TARGET/bin/lisa $DIR_TARGET/bin/lisa.big cp -a $DIR_BIN/mini-lisa $DIR_TARGET/bin/lisa fi Fix_ldconfig Fix_col22 elif [ "$1" = "after_postin" ]; then if [ -f /source/data/use-mini-lisa ]; then # install new lisa mv $DIR_TARGET/bin/lisa $DIR_TARGET/bin/mini-lisa mv $DIR_TARGET/bin/lisa.big $DIR_TARGET/bin/lisa fi # override old lisa-2.4.0 that was still in lisa-3.0-1 RPM if [ "`get_val -f $DIR_TARGET/bin/lisa SCRIPT_VERSION`" = "2.4.0" ]; then cp -a /bin/lisa $DIR_TARGET/bin/lisa fi # try to adjust the modules load files again uname_r="`Get_uname_r`" uname_v="`Get_uname_v`" # create modules load files again if kernels differ if [ "$uname_v" != "`uname -v`" ]; then if [ -f $DIR_TARGET/etc/modules/`uname -r`/"`uname -v`".default ]; then mkdir -p $DIR_TARGET/etc/modules/${uname_r} cp -a $DIR_TARGET/etc/modules/`uname -r`/"`uname -v`".default $DIR_TARGET/etc/modules/${uname_r}/"${uname_v}".default fi if [ -f $DIR_TARGET/etc/modules/`uname -r`/"`uname -v`".rootfs ]; then mkdir -p $DIR_TARGET/etc/modules/${uname_r} cp -a $DIR_TARGET/etc/modules/`uname -r`/"`uname -v`".rootfs $DIR_TARGET/etc/modules/${uname_r}/"$uname_v".rootfs fi # adjust the initrd again Set_modules_autoload Set_initrd fi fi } Do_All_Postin() { local script local short local postin_retval local pkg local num_done=0 local num_all=0 local percent=0 local label_header="`Do_Translate \":INFO_RPM_INSTALL_TITLE:\"` (postin)" mkdir $DIR_TARGET/install/postin.errors # calc number of postin scripts to execute num_all="`ls -l $DIR_TARGET/install/postin/* | get_info -l`" num_all="`do_calc $num_all - 1`" for script in $DIR_TARGET/install/postin/* ; do short="`basename $script`" if [ -f $script ]; then pkg="`echo $short | cut -c 6- `" # calc percentage done percent="`do_calc 100 \* $num_done`" percent="`do_calc $percent / $num_all`" # this would be the simple solution # Info "Processing postin scripts ($num_done/$num_all) ; ; Next script is from $pkg ; ; :INFO_WAIT:" $CMD_BOX --nobutton -P "$percent" --height 8 --width 60 -r --title "$label_header" --info "$pkg ($num_done/$num_all)" Debug "calling $script script" History_Install "calling $script ..." ( cd $DIR_TARGET; chroot $DIR_TARGET sh -c install/postin/$short ) > $DIR_TARGET/install/postin.errors/$short 2>&1 postin_retval=$? if [ $postin_retval -ne 0 ]; then echo "`date` $DIR_TARGET/install/postin/$short failed ($postin_retval)" >> $DIR_TARGET/var/adm/LST/log/postin.failed # Error "rpm postin of $short failed" fi # remove empty error logs if [ ! -s $DIR_TARGET/install/postin.errors/$short ]; then rm -f $DIR_TARGET/install/postin.errors/$short fi num_done="`do_calc $num_done + 1`" fi done echo "`date` ======== initial install done ========" >> $DIR_TARGET/var/adm/LST/log/postin.failed echo "`date` ======== initial install done ========" >> $DIR_TARGET/var/adm/LST/log/install.failed echo "`date` ======== initial install done ========" >> $DIR_TARGET/var/adm/LST/log/install.success return 0 } # raw installation of rpm pkgs # Do_Raw_rpm_Install() { local my_lang="`get_val CONF_LST_LANG`" local dir=`dirname $1` local file=`basename $1` local full=$1 local pkg=$2 local script= local size= local dummy local rpmextr_info local pkg_info local pkg_size local label_header="`Do_Translate \":INFO_RPM_INSTALL_TITLE:\"`" local label_file="`Do_Translate \":LABEL_FILE:\"`" local label_info="`Do_Translate \":LABEL_INFO:\"`" local label_installed="`Do_Translate \":LABEL_INSTALLED:\"`" local rpm_retval=0 local postin_retval=0 Debug "processing package $file start" Debug -d "params: <$*>" Get_Pkg_Info $full pkg_size="`do_calc $PKG_SIZE / 1024`" sum_installed="$PKG_NUM_DONE/$PKG_NUM_ALL ($PKG_KB_DONE/$PKG_KB_ALL kB)" if [ "$PKG_KB_DONE" -gt 0 -a "$PKG_KB_ALL" -gt 0 ]; then percent="`do_calc 100 \* $PKG_KB_DONE`" percent="`do_calc $percent / $PKG_KB_ALL`" elif [ "$PKG_NUM_ALL" -gt 0 -a "$PKG_KB_ALL" -gt 0 ]; then percent="`do_calc 100 \* $PKG_NUM_DONE`" percent="`do_calc $percent / $PKG_NUM_ALL`" else percent=0 sum_installed="$PKG_NUM_DONE ($PKG_KB_DONE kB)" fi # fix rounding bug if using kB instead of packages if [ "$percent" = "100" ]; then percent=99 fi Get_Filesystem_Usage --install > $FILE_TMP_MSG if [ "$my_lang" = "de" ]; then menutitle="Dateisystem Gr÷▀e(kB) frei(kB) benutzt Mountpunkt" else menutitle="Filesystem size(kB) free(kB) used mount point" fi # the rest is to be browsed... sed -e '1d' $FILE_TMP_MSG > $FILE_TMP_VAL Debug -D "FILE_TMP_VAL:" Debug -c cat $FILE_TMP_VAL $CMD_BOX --nobutton -P "$percent" -r --title "$label_header" --menutitle "$menutitle" --text "$label_file $file ($pkg_size kB) ; $label_installed $sum_installed ; ; $label_info $PKG_INFO" --browse $FILE_TMP_VAL History_Install "start installing ..." # FIXME: Do_Save_Conflicts should happen here Debug "extracting $full" Do_Unrpm $full rpm_retval=$? for script in doinst.sh doafter.sh ; do if [ -f $DIR_TARGET/install/$script ]; then Debug "calling $script script" History_Install "calling $script ..." if [ "$INSTALL_MODE" != "OpenLinux" ]; then ( cd $DIR_TARGET; chroot $DIR_TARGET sh -c install/$script ) 2>&1 | Debug -p postin_retval=$? fi mv $DIR_TARGET/install/$script $DIR_LOG_SCRIPTS/$PKG_NAME.$script fi done PKG_NUM_DONE=`do_calc $PKG_NUM_DONE + 1 ` size="` do_calc $PKG_SIZE / 1024 `" PKG_KB_DONE=`do_calc $PKG_KB_DONE + $size ` Debug "processing package $file done" if [ "$rpm_retval" != 0 -o "$postin_retval" != 0 ]; then History_Install "installation of $file failed ($rpm_retval/$postin_retval)" echo "`date` installation of $file failed ($rpm_retval/$postin_retval)" >> $DIR_TARGET/var/adm/LST/log/install.failed return 1 else History_Install "installation sucessfully completed" echo "`date` installation of $file was ok ($rpm_retval/$postin_retval)" >> $DIR_TARGET/var/adm/LST/log/install.success return 0 fi } Get_Install_Stat() { if [ -s $FILE_PKGS_SEL ]; then export PKG_NUM_ALL="`get_info -lf $FILE_PKGS_SEL`" Debug "PKG_NUM_ALL=<$PKG_NUM_ALL>" else export PKG_NUM_ALL=0 fi if [ -s $FILE_PKGS_SEL -a -s $FILE_PKGS_DATA ]; then if [ -z "$NEEDSPACE" ]; then NEEDSPACE=0 fi if [ "$NEEDSPACE" -eq "0" ]; then Info ":INFO_CALCULATING_PKG_SIZES:" build_menu -t $FILE_PKGS_SEL -d $FILE_PKGS_DATA -S | cut -d':' -f 7 > /tmp/val else do_calc $NEEDSPACE / 1024 > /tmp/val fi export PKG_KB_ALL="`cat /tmp/val`" Debug "PKG_KB_ALL=<$PKG_KB_ALL>" else export PKG_KB_ALL=0 fi export PKG_NUM_DONE=0 export PKG_KB_DONE=0 } Get_Pkg_Info() { local f_name=Get_Pkg_Info local f_args=1 # (pkg_name/pkg_file) -> local tmpfile=/tmp/pkginfo.$$ local my_lang="`get_val CONF_LST_LANG`" local pkg_dict=$FILE_PKGS_INDEX export PKG_SERVICE="unknown" export PKG_NAME="unknown" export PKG_SEL="unknown" export PKG_PRIO="unknown" export PKG_PRIORITY="unknown" export PKG_SIZE="unknown" export PKG_DISK="unknown" export PKG_USAGE="unknown" export PKG_VERS="unknown" export PKG_RELEASE="unknown" export PKG_GROUP="unknown" export PKG_SERVICE="unknown" export PKG_SERIES="unknown" export PKG_INFO="unknown" export PKG_COPYRIGHT="unknown" export PKG_SRC="unknown" export PKG_VENDOR="unknown" export PKG_DISTRIBUTION="unknown" Check_Args $f_name $f_args $# "$@" || return 255 if [ -f /usr/lib/LST/$my_lang/pkgs.idx ]; then pkg_dict=/usr/lib/LST/$my_lang/pkgs.idx fi PKG_FILE="$1" Check_File $PKG_FILE if [ $? -eq 0 ]; then # arg was a file name Do_Find_Pkg_To_File $PKG_FILE || return 1 else # arg probably was a pkg name PKG_NAME="$1" Do_Find_File_To_Pkg $PKG_NAME || return 1 fi # Get specific pkg info case $PKG_TYPE in rpm) # get data from rpm header rpmextr --shell $PKG_FILE > $tmpfile . $tmpfile rm -f $tmpfile # get data from pkgs.db db_printf -n -m ":1:$PKG_NAME:" -p ":3:4:5:-6:7:" -f $FILE_PKGS_DATA > $tmpfile if [ -s $tmpfile ]; then read PKG_SEL PKG_PRIO PKG_SIZE PKG_DISK PKG_USAGE < $tmpfile fi rm -f $tmpfile ;; esac # get package description (multilingual) PKG_INFO="`Do_Translate \":$PKG_NAME:\" $pkg_dict`" if [ "$PKG_INFO" = ":$PKG_NAME:" ]; then PKG_INFO="`rpmextr --tag=info $file`" if [ -z "$PKG_INFO" ]; then PKG_INFO="unknown" fi fi # selected if it is in the selection list if [ -n "$FILE_PKGS_SEL" ]; then if [ -s $FILE_PKGS_SEL ]; then Check_Found "$PKG_NAME" "$FILE_PKGS_SEL" if [ $? -eq 0 ]; then PKG_SEL=j else PKG_SEL=n fi else PKG_SEL= fi fi # get real pkg usage if [ -z "$PKG_SIZE" ]; then PKG_SIZE="`gzip -l $PKG_FILE | fgrep '%' | cut -c 10-20`" fi # get real file size if [ -n "$PKG_FILE" ]; then PKG_USAGE="`filesize $PKG_FILE`" fi if [ -n "$PKG_PRIO" -a "$PKG_PRIO" != "unknown" ]; then PKG_PRIORITY="`Do_Translate \":TYPE_PRIO_$PKG_PRIO:\"`" if [ "$PKG_PRIORITY" = ":TYPE_PRIO_$PKG_PRIO:" ]; then PKG_PRIORITY="unknown" fi fi if [ -n "$PKG_DISK" -a "$PKG_DISK" != "unknown" ]; then PKG_SERIES="`echo $PKG_DISK | sed 's/[0-9]*$//'`" fi } # Get_Pkg_Type FILE # Get_Pkg_Type() { local f_name=Get_Pkg_Type local f_args=1 # (file) -> PKG_TYPE, PKGEXT local pkgtype local pkgext export PKG_TYPE=unknown export PKGEXT=unknown Check_Args $f_name $f_args $# "$@" || return 255 for pkgtype in rpm ; do case $pkgtype in rpm) if [ "`basename $1 .$pkgtype`" != "`basename $1`" ]; then PKGEXT="$pkgtype" PKG_TYPE="$pkgtype" return 0 fi ;; esac done # FIXME: fallback for trans.tbl mode -> assume rpm PKGEXT="rpm" PKG_TYPE="rpm" return 0 Error "$1 ; :ERR_UNKNOWN_PKGTYPE:" return 1 } Has_Selections() { Check_File $FILE_PKGS_SEL && return 0 Msg ":ERR_MISSING_SELECTIONS:" return 1 } Has_Source() { if [ -z "$DIR_SOURCE" ]; then Error ":ERR_MISSING_SOURCE:" return 1 fi return 0 } Has_Pkgs() { if [ -z "$DIR_PKGS" ]; then Error ":ERR_MISSING_SOURCE:" return 1 fi if [ ! -d "$DIR_PKGS/RPMS" ]; then return 1 fi return 0 } # checks if target path is valid # Has_Target_Path() { local f_name=Has_Target_Path local f_args=0 # DIR_TARGET -> Check_Args $f_name $f_args $# "$@" || return 255 if [ -z "$DIR_TARGET" ]; then Error ":ERR_MISSING_TARGET_PATH:" return 1 fi if [ ! -d "$DIR_TARGET" ]; then Error "$DIR_TARGET ; :ERR_INVALID_TARGET_PATH:" return 1 fi return 0 } Menu_Pkg() { local cmd= # "Menu_Pkg_Select" ":MENU_PKG_SELECT:" while [ 1 ]; do $CMD_BOX --help ":MENU_PKG_HELP:" \ --title ":MENU_PKG_TITLE:" \ --menu ":MENU_PKG_TEXT:" \ "Choose_Install_Source" ":CHOOSE_INSTALL_SOURCE:" \ "Menu_Pkg_Info" ":MENU_PKG_INFO:" \ "Menu_Pkg_Add" ":MENU_PKG_ADD:" \ "Menu_Pkg_Remove" ":MENU_PKG_REMOVE:" 2> $FILE_TMP_ANSWER if [ $? -ne 0 ]; then Debug "Menu_Pkg submenu retval -ne 0 !" return 1 fi if [ -s $FILE_TMP_ANSWER ]; then cmd="`cat $FILE_TMP_ANSWER`" if [ -n "$cmd" ]; then $cmd else Debug "Menu_Pkg leaves empty command !" fi else Debug "Menu_Pkg leaves empty $FILE_TMP_ANSWER !" fi done } Menu_Pkg_Info() { Info_lite ":INFO_BUILDING_PKGLIST: :INFO_WAIT:" Choose --menutitle ":MENU_SHOW_PKGS_MENUTITLE:" --build "Build_RPM_Infos" PKG_INFO || return 1 rpm -qi "$ANSWER" > /tmp/LST/val 2> /dev/null if [ $? -eq 0 ]; then $CMD_BOX --browse /tmp/LST/val fi return 0 } List_RPM_Installed() { rpm -qa | sed 's/^\(.*\)-[^-]*-[^-]*$/\1/' | sort | uniq } List_Pkgs_Known() { build_menu -d $FILE_PKGS_DATA -n -p ":1:" | sort | uniq } List_Pkgs_Not_Installed() { local p local known=/tmp/LST/pkgs.known local inst=/tmp/LST/pkgs.inst List_Pkgs_Known > $known List_RPM_Installed > $inst # fgrep -v -f $inst $known for p in `cat $known` ; do if [ -z "`fgrep -x $p $inst`" ]; then echo "$p" fi done } Build_RPM_Installed() { touch $FILE_PKGS_SEL build_menu -R -t $FILE_PKGS_SEL -d $FILE_PKGS_DATA -f } Build_RPM_Infos() { List_RPM_Installed | do_quote } Build_Pkgs_Not_Installed() { touch $FILE_PKGS_SEL build_menu -R -t $FILE_PKGS_SEL -d $FILE_PKGS_DATA -f } Do_Pkg_Add() { local p=$1 local pfile Do_Find_File_To_Pkg $p pfile="$PKG_FILE" Debug "Install $p ($pfile)" Do_Raw_rpm_Install $pfile $p return 0 } Menu_Pkg_Add() { local p Has_Pkgs || return 1 Info_lite ":INFO_BUILDING_PKGLIST: :INFO_WAIT:" List_Pkgs_Not_Installed > $FILE_PKGS_SEL Choose --menutitle ":MENU_SHOW_PKGS_MENUTITLE:" --sumlist --build "Build_Pkgs_Not_Installed" PKG_SELECT_PKGS || return 1 mv $FILE_TMP_ANSWER $FILE_PKGS_SEL if [ ! -s $FILE_PKGS_SEL ]; then return 1 fi Msg2 PKG_INSTALL || continue Info ":INFO_INSTALLING_PKG: :INFO_WAIT:" Do_Sort_Pkgs Do_Sort_Series Get_Install_Stat for p in `cat $FILE_PKGS_SEL` ; do Do_Pkg_Add $p done rm -f $FILE_PKGS_SEL return 0 } Menu_Pkg_Remove() { local p Info_lite ":INFO_BUILDING_PKGLIST: :INFO_WAIT:" List_RPM_Installed > $FILE_PKGS_SEL Choose --menutitle ":MENU_SHOW_PKGS_MENUTITLE:" --sumlist --build "Build_RPM_Installed" PKG_REMOVE || return 1 mv $FILE_TMP_ANSWER $FILE_PKGS_SEL if [ -s $FILE_PKGS_SEL ]; then Info ":INFO_REMOVING_PKGS: :INFO_WAIT:" for p in `cat $FILE_PKGS_SEL` ; do Do_Pkg_Remove $p done fi rm -f $FILE_PKGS_SEL return 0 } Do_Check_Freespace() { local TOTALSPACE= local need_MB= local free_MB= # calculate the needed space Do_Calc_Needspace $FILE_PKGS_SEL Debug "NEEDSPACE='$NEEDSPACE'" # calculate the free space Do_Calc_Freespace $DIR_TARGET # to get on the save side, we require an additional SPARESPACE TOTALSPACE=`do_calc $NEEDSPACE + $SPARESPACE` Debug "TOTALSPACE='$TOTALSPACE', FREESPACE='$FREESPACE'" free_MB="`do_calc $FREESPACE / 1048576`" need_MB="`do_calc $TOTALSPACE / 1048576`" if [ "$free_MB" = "$need_MB" ]; then need_MB="`do_calc $need_MB + 1`" fi if [ $need_MB -gt $free_MB ]; then if [ $free_MB -gt 0 ]; then Warn "($need_MB MB > $free_MB MB) ; :ERR_USR_TOO_SMALL:" || return 1 else Debug "Warning free_MB is negative ($free_MB) Integer overflow?" fi fi return 0 } Menu_Pkg_Select() { prep_use INSTALL || return 1 prep_use RPM_INSTALL || return 1 Has_Source || return 1 Has_Target_Path || return 1 Check_Pkg_Database || return 1 Check_Pkg_Index || return 1 Info ":INFO_WAIT:" while [ 1 ]; do if [ "`get_val -f /etc/lst.cnf CONF_COL_EDITION`" = "SBA" ]; then build_menu -n -p ":1:" -d $FILE_PKGS_DATA > /usr/lib/LST/pkgs.sel ANSWER="Menu_Pkg_Select_Preset sel" else if [ -f /usr/lib/LST/pkgs.sel ]; then Choose --prefix "MENU" --default "Menu_Pkg_Select_Preset sel" --build "Build_PKG_SELECT" PKG_SELECT || return 1 else Choose --prefix "MENU" --default "Menu_Pkg_Select_Preset rec" --build "Build_PKG_SELECT" PKG_SELECT || return 1 fi fi COMMAND="$ANSWER" $COMMAND || continue Do_Check_Freespace || continue break done # save final package selection if [ -f $FILE_PKGS_SEL ]; then cp -a $FILE_PKGS_SEL /usr/lib/LST/pkgs.sel fi return 0 } Menu_Pkg_Select_Pkgs() { rm -f $FILE_SERIES_SEL rm -f $FILE_PKGS_SEL Info_lite ":INFO_BUILDING_PKGLIST: :INFO_WAIT:" touch $FILE_PKGS_SEL # generate pkglist from pkgs.db build_menu -s basis -c 2 -f -d $FILE_PKGS_DATA > /tmp/LST/HOPE Choose --menutitle ":MENU_SHOW_PKGS_MENUTITLE:" --sumlist --build "Build_PKG" PKG_SELECT_PKGS || return 1 mv $FILE_TMP_ANSWER $FILE_PKGS_SEL # generate serieslist from pkglist Info_lite ":INFO_UPDATING_SELECTIONS:" build_menu -U 0 -t $FILE_PKGS_SEL -d $FILE_PKGS_DATA | db_printf -p ":-2:-3:" | fgrep -v ':0' | db_printf -p ":1:" > $FILE_SERIES_SEL return 0 } Menu_Pkg_Select_Preset() { local preset=$1 # initially NEEDSPACE is in MB export NEEDSPACE=0 # generate selection list depending on the preset type Get_Preset_Pkgs $preset > $FILE_PKGS_SEL # generate serieslist from pkglist Info_lite ":INFO_UPDATING_SELECTIONS:" build_menu -U 0 -t $FILE_PKGS_SEL -d $FILE_PKGS_DATA | db_printf -p ":-2:-3:" | fgrep -v ':0' | db_printf -p ":1:" > $FILE_SERIES_SEL # ask for X Server if recommended pkgs if [ "$preset" = "minx" -o "$preset" = "small" -o "$preset" = "rec" ]; then while [ 1 ]; do Choose --sumlist --build "build_menu -f -u XSERV -d $FILE_PKGS_DATA" PKG_SELECT_SERVICES_XSERVER || return 1 if [ ! -s $FILE_TMP_ANSWER ]; then Error ":ERR_NEED_AT_LEAST_ONE_XSERVER:" continue fi cat $FILE_TMP_ANSWER >> $FILE_PKGS_SEL break done fi return 0 } Menu_Pkg_Select_Series() { local series= local choice= local retval= # reset all selections Info_lite ":INFO_BUILDING_SERIESLIST:" rm -f $FILE_PKGS_SEL rm -f $FILE_SERIES_SEL for i in $LST_SERIES ; do rm -f $DIR_LST_TMP/$i.sel done # loop for all series while [ 1 ]; do Choose --menutitle ":MENU_SHOW_SERIES_MENUTITLE:" --menu --build Build_SERIES PKG_SELECT_SERIES retval=$? if [ $retval -eq 255 ]; then return 255 fi if [ $retval -ne 0 ]; then # workaround for unclear continue/abort if [ -f $FILE_PKGS_SEL ]; then ANSWER=ENDE else return 1 fi fi SERIES="$ANSWER" if [ "$ANSWER" = "USAGE" ]; then Show_Filesystem_Usage $DIR_TARGET continue fi if [ "$ANSWER" = "ENDE" ]; then if [ "$DIR_TARGET" = "/" ]; then return 0 fi if [ -s $FILE_SERIES_SEL ]; then fgrep -x "basis" $FILE_SERIES_SEL >/dev/null if [ $? -eq 0 ]; then return 0 fi fi Msg ":ERR_NO_BASIS_SELECTED:" continue fi Choose --build "Build_SELECT_PRIO $SERIES" SELECT_PRIO || continue CHOICE="$ANSWER" if [ "$CHOICE" = "0" ]; then if [ -s $DIR_LST_TMP/$SERIES.sel -a -s $FILE_PKGS_SEL ]; then fgrep -vxf $DIR_LST_TMP/$SERIES.sel $FILE_PKGS_SEL > $FILE_PKGS_SEL.tmp mv $FILE_PKGS_SEL.tmp $FILE_PKGS_SEL fi rm -f $DIR_LST_TMP/$SERIES.sel if [ -s $FILE_SERIES_SEL -a -n "$SERIES" ]; then fgrep -vx "$SERIES" $FILE_SERIES_SEL > $FILE_SERIES_SEL.tmp mv $FILE_SERIES_SEL.tmp $FILE_SERIES_SEL fi continue fi Info_lite ":INFO_BUILDING_PKGLIST: :INFO_WAIT:" touch $FILE_PKGS_SEL if [ "$CHOICE" = "4" ]; then build_menu -T $FILE_PKGS_SEL -d $FILE_PKGS_DATA | build_menu -N -s $SERIES -T $DIR_LST_TMP/$SERIES.sel -f > /tmp/LST/HOPE else build_menu -T $FILE_PKGS_SEL -d $FILE_PKGS_DATA | build_menu -N -s $SERIES -c $CHOICE -f > /tmp/LST/HOPE fi Choose --menutitle ":MENU_SHOW_PKGS_MENUTITLE:" --sumlist --build "Build_PKG" PKG_SELECT_PKGS || continue Info_lite ":INFO_UPDATING_SELECTIONS:" # update selectlist mv $FILE_TMP_ANSWER $DIR_LST_TMP/$SERIES.sel rm -f $FILE_PKGS_SEL for i in $LST_SERIES ; do if [ -s $DIR_LST_TMP/$i.sel ]; then cat $DIR_LST_TMP/$i.sel >> $FILE_PKGS_SEL else rm -f $DIR_LST_TMP/$i.sel fi done # update serieslist touch $FILE_SERIES_SEL if [ -z "`fgrep -x $SERIES $FILE_SERIES_SEL`" ]; then if [ "$SERIES" = "basis" ]; then echo "$SERIES" > $FILE_SERIES_SEL.tmp cat $FILE_SERIES_SEL >> $FILE_SERIES_SEL.tmp mv $FILE_SERIES_SEL.tmp $FILE_SERIES_SEL else echo "$SERIES" >> $FILE_SERIES_SEL fi fi done return 0 } Menu_Pkg_Select_Services() { local i= local servok=0 local shadsel=0 local xsel=0 local docsel=0 local textsel=0 local gamessel=0 local develsel=0 local netsel=0 local servsel=0 local develdocsel=0 local netshadsel=0 local netdocsel=0 local netservsel=0 local xshadsel=0 local xtextsel=0 local xgamessel=0 local xnetsel=0 local xdevelsel=0 local xdeveldocsel=0 while [ 1 ]; do # reset all selections rm -f $FILE_PKGS_SEL i= shadsel=0 xsel=0 docsel=0 textsel=0 gamessel=0 develsel=0 netsel=0 servsel=0 develdocsel=0 netshadsel=0 netdocsel=0 netservsel=0 xshadsel=0 xtextsel=0 xgamessel=0 xnetsel=0 xdevelsel=0 xdeveldocsel=0 # offer all MAIN choices echo "MAIN" > $FILE_META_SEL # for now we need SHADOW by default echo "SHAD" >> $FILE_META_SEL shadsel=1 # ask for additional services (meta level) $CMD_BOX --multi ":CHOOSE_SERVICES:" \ --help ":CHOOSE_SERVICES_HELP:" \ "X" ":TYPE_SERVICE_X:" S \ "DOC" ":TYPE_SERVICE_DOC:" S \ "TEXT" ":TYPE_SERVICE_TEXT:" S \ "GAMES" ":TYPE_SERVICE_GAMES:" U \ "DEVEL" ":TYPE_SERVICE_DEVEL:" U \ "NET" ":TYPE_SERVICE_NET:" U \ "SERV" ":TYPE_SERVICE_SERV:" U 2>> $FILE_META_SEL || return 1 servok= # reset all selections rm -f $FILE_PKGS_SEL fgrep -x X $FILE_META_SEL > /dev/null if [ $? -eq 0 ]; then while [ 1 ]; do # ask for X Server Choose --sumlist --build "build_menu -f -u XSERV -d $FILE_PKGS_DATA" PKG_SELECT_SERVICES_XSERVER || return 1 if [ ! -s $FILE_TMP_ANSWER ]; then Error ":ERR_NEED_AT_LEAST_ONE_XSERVER:" continue fi cat $FILE_TMP_ANSWER >> $FILE_PKGS_SEL servok=1 break done else servok=1 fi Info_lite ":INFO_BUILDING_SERVICELIST:" # analyse selections fgrep -x X $FILE_META_SEL > /dev/null && xsel=1 fgrep -x DOC $FILE_META_SEL > /dev/null && docsel=1 fgrep -x TEXT $FILE_META_SEL > /dev/null && textsel=1 fgrep -x GAMES $FILE_META_SEL > /dev/null && gamessel=1 fgrep -x DEVEL $FILE_META_SEL > /dev/null && develsel=1 fgrep -x NET $FILE_META_SEL > /dev/null && netsel=1 fgrep -x SERV $FILE_META_SEL > /dev/null && servsel=1 # hardcoded rules ;-) # devel rules if [ $develsel -eq 1 -a $docsel -eq 1 ]; then develdocsel=1 echo "DEVELDOC" >> $FILE_META_SEL fi # # net rules # if [ $netsel -eq 1 -a $shadsel -eq 1 ]; then netshadsel=1 echo "NETSHAD" >> $FILE_META_SEL fi if [ $netsel -eq 1 -a $docsel -eq 1 ]; then netdocsel=1 echo "NETDOC" >> $FILE_META_SEL fi if [ $netsel -eq 1 -a $servsel -eq 1 ]; then netservsel=1 echo "NETSERV" >> $FILE_META_SEL fi # # X rules # if [ $xsel -eq 1 -a $shadsel -eq 1 ]; then xshadsel=1 echo "XSHAD" >> $FILE_META_SEL fi if [ $xsel -eq 1 -a $textsel -eq 1 ]; then xtextsel=1 echo "XTEXT" >> $FILE_META_SEL fi if [ $xsel -eq 1 -a $gamessel -eq 1 ]; then xgamessel=1 echo "XGAMES" >> $FILE_META_SEL fi if [ $xsel -eq 1 -a $netsel -eq 1 ]; then xnetsel=1 echo "XNET" >> $FILE_META_SEL fi if [ $xsel -eq 1 -a $develsel -eq 1 ]; then xdevelsel=1 echo "XDEVEL" >> $FILE_META_SEL fi if [ $xsel -eq 1 -a $develdocsel -eq 1 ]; then xdeveldocsel=1 echo "XDEVELDOC" >> $FILE_META_SEL fi # generate servicelist rm -f $FILE_SERVICES_SEL for i in `cat $FILE_META_SEL` ; do fgrep ":$i:" $FILE_META_DATA | cut -d':' -f 3 >> $FILE_SERVICES_SEL done echo "$CMD_BOX -a --help \":MENU_PKG_SELECT_SERVICES_HELP:\" \\" > $FILE_TMP_COMMAND echo "--sumlist \":MENU_PKG_SELECT_SERVICES_TEXT:\" \\" >> $FILE_TMP_COMMAND for i in `cat $FILE_SERVICES_SEL` ; do Debug "# build_menu -S -f -u $i -d $FILE_PKGS_DATA" build_menu -S -f -u $i -d $FILE_PKGS_DATA >> $FILE_TMP_COMMAND done rm -f $FILE_SERVICES_SEL echo "2> $FILE_TMP_MSG" >> $FILE_TMP_COMMAND chmod 755 $FILE_TMP_COMMAND # choose services sh $FILE_TMP_COMMAND && break done Info_lite ":INFO_BUILDING_SERVICELIST:" # generate pkglist mv $FILE_TMP_MSG $FILE_SERVICES_SEL for i in `cat $FILE_SERVICES_SEL` ; do build_menu -u $i -n -p ":1:" -d $FILE_PKGS_DATA >> $FILE_PKGS_SEL done # generate serieslist from pkglist Info_lite ":INFO_UPDATING_SELECTIONS:" build_menu -U 0 -t $FILE_PKGS_SEL -d $FILE_PKGS_DATA | db_printf -p ":-2:-3:" | fgrep -v ':0' | db_printf -p ":1:" > $FILE_SERIES_SEL return 0 } # libLSTuser - user administration library shared between several scripts # # Copyright (C) 1993-1997 Ralf Flaxa, LST Software GmbH, Erlangen, Germany # List_USER() { db_printf -n -p ":-1:3:4:-5:" -f $FILE_ETC_PASSWD } Build_USER() { List_USER | do_quote } Build_USER_DEL() { # filter out system and NIS users. should not be deleted. List_USER | sed '{ /^root /d /^bin /d /^daemon /d /^adm /d /^lp /d /^sync /d /^shutdown /d /^halt /d /^mail /d /^news /d /^uucp /d /^operator /d /^games /d /^gopher /d /^ftp /d /^man /d /^nobody /d /^+/d }' | do_quote } List_GROUP() { db_printf -n -p ":-1:3:4:" -f $FILE_ETC_GROUP } Build_GROUP() { List_GROUP | do_quote } Check_GID_Known() { local f_name=Check_GID_Known local f_args=1 # (gid) -> Check_Args $f_name $f_args $# "$@" || return 255 if [ -n "`cut -d':' -f 3 $FILE_ETC_GROUP | sed -n "/^$1$/p"`" ] then return 0 else return 1 fi } Check_Group_Known() { local f_name=Check_Group_Known local f_args=1 # (groupname) -> Check_Args $f_name $f_args $# "$@" || return 255 if [ -n "`sed -n "/^$1:/p" $FILE_ETC_GROUP`" ] then return 0 else return 1 fi } Check_UID_Known() { local f_name=Check_UID_Known local f_args=1 # (uid) -> Check_Args $f_name $f_args $# "$@" || return 255 if [ -n "`cut -d':' -f 3 $FILE_ETC_PASSWD | sed -n "/^$1$/p"`" ]; then return 0 else return 1 fi } Check_User_Known() { local f_name=Check_User_Known local f_args=1 # (username) -> Check_Args $f_name $f_args $# "$@" || return 255 if [ -n "`sed -n "/^$1:/p" $FILE_ETC_PASSWD`" ]; then return 0 else return 1 fi } Get_Next_UID() { local start_uid=500 local stop_uid=65534 local curr_uid=$start_uid while [ 1 ]; do if Check_UID_Known $curr_uid ; then curr_uid="`do_calc $curr_uid + 1`" else break fi # stop searching at user nobody if [ $curr_uid -eq $stop_uid ]; then echo "" return 1 fi done echo "$curr_uid" return 0 } Menu_User_Add() { local newusername= local newuseruid= local newusergroup= local newusergid= local newuserhome= local newusershell= local newusergecos= local homeprefix= local skipall= if [ $# -gt 0 -a "X$1" = 'X--first' ]; then newusername=col newuseruid=500 newusergroup=users newusergid=100 newuserhome=/home/col newusershell=/bin/bash newusergecos="Caldera OpenLinux User" homeprefix=/home #skipall=true fi # ask logname while [ 1 ]; do if [ "$skipall" = "true" ]; then break fi while [ 1 ]; do while [ 1 ]; do Ask_String LOGNAME_USER $newusername || return 1 newusername="$ANSWER" if [ "$newusername" != "`echo $newusername | sed 's/ //'`" ]; then Error "<$newusername> ; a username may not contain any spaces." continue fi if [ -n "$newusername" ]; then break fi done if Check_User_Known $newusername ; then Error "$newusername ; :ERR_LOGNAME_EXISTS:" continue else break fi done # ask UID while [ 1 ]; do if [ -z "$newuseruid" ]; then newuseruid="`Get_Next_UID`" fi Ask_String UID_USER $newuseruid || return 1 newuseruid="$ANSWER" if [ -z "$newuseruid" ]; then continue fi if Check_UID_Known $newuseruid ; then Error "$newuserid ; :ERR_UID_EXISTS:" continue else break fi done # ask group newusergroup="`Get_Val CONF_GROUP_DEFAULT`" Choose --build Build_GROUP GROUP_USER $newusergroup || return 1 newusergroup="$ANSWER" newusergid="`sed -n "/^$newusergroup:/p" $FILE_ETC_GROUP | cut -d':' -f 3`" # ask home newuserhome="`Get_Val CONF_HOME_DEFAULT`" if [ -z "$newuserhome" ]; then newuserhome=/home fi newuserhome="$newuserhome/$newusername" Ask_String HOME_USER $newuserhome || return 1 newuserhome="$ANSWER" homeprefix="`echo $newuserhome | sed 's,^\(.*\)/[^/]*,\1,'`" # ask shell newusershell="`Get_Val CONF_SHELL_DEFAULT`" Choose --build "List box SHELL" SHELL_USER $newusershell || return 1 newusershell="$ANSWER" # ask comment field Ask_String COMMENT_USER "$newusergecos" || return 1 newusergecos="$ANSWER" if [ -n "$newusergecos" ]; then gecos="-c \"$newusergecos\"" fi break done # Note: expire date is still set statically to 31th Dec 1999 (-e 10956) # Ask_String EXPIRE_DATE $CONF_ACCOUNT_EXPIRE_DATE # expire_date="$ANSWER" expire_date="10956" # FIXME: useradd now comes from the live filesystem # prep_use /usr/sbin/useradd mkdir -p $homeprefix if [ -n "$newusergecos" ]; then useradd -g "$newusergid" -u "$newuseruid" -c "$newusergecos" -d "$newuserhome" -s "$newusershell" -m "$newusername" || continue else useradd -g "$newusergid" -u "$newuseruid" -d "$newuserhome" -s "$newusershell" -m "$newusername" || continue fi chmod 644 $DIR_TARGET/etc/passwd mkdir -p $DIR_TARGET/$newuserhome if [ -d $DIR_TARGET/etc/skel ]; then cp -a $DIR_TARGET/etc/skel/. $DIR_TARGET/$newuserhome fi chown -R $newuseruid.$newusergid $DIR_TARGET/$newuserhome LAST_USER="$newusername" Do_Set_Password $newusername return 0 } Menu_User_Del() { local deluser= Choose --build Build_USER_DEL USER_DEL || return 1 deluser="$ANSWER" $CMD_BOX --help ":ASK_USER_DEL_ACK_HELP:" \ --title ":ASK_USER_DEL_ACK_TITLE:" \ --bool "$deluser ; :ASK_USER_DEL_ACK_TEXT:" 2> $FILE_TMP_ANSWER || return 1 touch $FILE_TMP_ANSWER ANSWER="`cat $FILE_TMP_ANSWER`" rm -f $FILE_TMP_ANSWER if [ "$ANSWER" = "0" ]; then $DO_SIMULATE userdel -r $deluser fi } Menu_User_Show() { List_USER > $FILE_TMP_MSG $CMD_BOX --help ":MENU_SHOW_USER_HELP:" \ --title ":MENU_SHOW_USER_TITLE:" \ --menutitle ":MENU_SHOW_USER_MENUTITLE:" \ --text ":MENU_SHOW_USER_TEXT:" \ --browse $FILE_TMP_MSG 2> /dev/null } Menu_Group_Add() { local newgrp= local newgid= Ask_String GROUP_ADD || return 1 newgrp="$ANSWER" Ask_String GROUP_GID || return 1 newgid="$ANSWER" $CMD_BOX --help ":ASK_GROUP_ADD_ACK_HELP:" \ --title ":ASK_GROUP_ADD_ACK_TITLE:" \ --bool ":ASK_GROUP_ADD_ACK_TEXT:" 2> $FILE_TMP_ANSWER || return 1 touch $FILE_TMP_ANSWER ANSWER="`cat $FILE_TMP_ANSWER`" rm -f $FILE_TMP_ANSWER if [ "$ANSWER" = "0" ]; then $DO_SIMULATE groupadd -g $newgid $newgrp fi } Menu_Group_Del() { local delgroup= Choose --build Build_GROUP GROUP_DEL || return 1 delgroup="$ANSWER" $CMD_BOX --help ":ASK_GROUP_DEL_ACK_HELP:" \ --title ":ASK_GROUP_DEL_ACK_TITLE:" \ --bool ":ASK_GROUP_DEL_ACK_TEXT:" 2> $FILE_TMP_ANSWER || return 1 touch $FILE_TMP_ANSWER ANSWER="`cat $FILE_TMP_ANSWER`" rm -f $FILE_TMP_ANSWER if [ "$ANSWER" = "0" ]; then $DO_SIMULATE groupdel $delgroup fi } Menu_Group_Show() { List_GROUP > $FILE_TMP_MSG $CMD_BOX --help ":MENU_SHOW_GROUP_HELP:" \ --title ":MENU_SHOW_GROUP_TITLE:" \ --menutitle ":MENU_SHOW_GROUP_MENUTITLE:" \ --text ":MENU_SHOW_GROUP_TEXT:" \ --browse $FILE_TMP_MSG 2> /dev/null } Menu_Config_Group_Default() { Choose --build Build_GROUP GROUP_DEFAULT || return 1 Do_Store CONF_GROUP_DEFAULT "$ANSWER" } Menu_Config_Home_Default() { Ask_String HOME_DEFAULT || return 1 Do_Store CONF_HOME_DEFAULT "$ANSWER" || return 1 return 0 } Menu_Config_Shell_Default() { Choose SHELL SHELL_DEFAULT || return 1 Do_Store CONF_SHELL_DEFAULT "$ANSWER" || return 1 return 0 } Menu_User_Defaults() { local defshell local defhome local defgroup while [ 1 ]; do $CMD_BOX --help ":MENU_USER_DEFAULTS_HELP:" \ --title ":MENU_USER_DEFAULTS_TITLE:" \ --menu ":MENU_USER_DEFAULTS_TEXT:" \ "Menu_Config_Shell_Default" ":CHOOSE_SHELL_DEFAULT: (`Get_Val CONF_SHELL_DEFAULT`)" \ "Menu_Config_Home_Default" ":ASK_HOME_DEFAULT: (`Get_Val CONF_HOME_DEFAULT`)" \ "Menu_Config_Group_Default" ":CHOOSE_GROUP_DEFAULT: (`Get_Val CONF_GROUP_DEFAULT`)" 2> $FILE_TMP_ANSWER || break COMMAND="`cat $FILE_TMP_ANSWER`" $COMMAND done return 0 } Menu_Config_User() { local item= Check_Chroot ":MENU_CONFIG_USER:" || return 1 while [ 1 ]; do if [ -z "$item" ]; then item="Menu_User_Show" ; fi $CMD_BOX --help ":MENU_CONFIG_USER_HELP:" \ --default "$item" \ --title ":MENU_CONFIG_USER_TITLE:" \ --menu ":MENU_CONFIG_USER_TEXT:" \ "Menu_User_Show" ":MENU_SHOW_USER:" \ "Menu_User_Add" ":MENU_USER_ADD:" \ "Menu_User_Del" ":MENU_USER_DEL:" \ "Menu_Group_Show" ":MENU_SHOW_GROUP:" \ "Menu_Group_Add" ":MENU_GROUP_ADD:" \ "Menu_Group_Del" ":MENU_GROUP_DEL:" \ "Menu_User_Defaults" ":MENU_USER_DEFAULTS:" 2> $FILE_TMP_ANSWER || break COMMAND="`cat $FILE_TMP_ANSWER`" item="$COMMAND" $COMMAND done return 0 }